Skip to content

Instantly share code, notes, and snippets.

@recursivecodes
Created August 15, 2019 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save recursivecodes/6087e85622d5e497e47c9dd88065c2b6 to your computer and use it in GitHub Desktop.
Save recursivecodes/6087e85622d5e497e47c9dd88065c2b6 to your computer and use it in GitHub Desktop.
KmsDemoFunctionTest.java
package codes.recursive;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fnproject.fn.testing.*;
import org.junit.*;
import java.io.IOException;
import java.util.Map;
import static org.junit.Assert.*;
public class KmsDemoFunctionTest {
    @Rule
    public final FnTestingRule testing = FnTestingRule.createDefault();
    @Test
    public void shouldDecryptPassword() throws IOException {
        testing.givenEvent().enqueue();
        testing.thenRun(KmsDemoFunction.class, "decryptSensitiveValue");
        FnResult result = testing.getOnlyResult();
        System.out.println(result.getBodyAsString());
        Map<String, String> resultMap = new ObjectMapper().readValue(result.getBodyAsString(), Map.class);
        assertEquals("hunter2", resultMap.get("decryptedPassword"));
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment