From 29e3cd1afbd3202a0c16ef6a4057662942ddefa2 Mon Sep 17 00:00:00 2001 From: sebdet Date: Thu, 13 Feb 2020 05:49:21 -0800 Subject: Add tests Add tests for https and aaf Issue-ID: CLAMP-624 Signed-off-by: sebdet Change-Id: Ia78ed8da7e54eaeaaed4fb87f483e0aff3a4a8c5 --- .../policy/downloader/PolicyEngineControllerTestItCase.java | 10 ++++++++++ src/test/java/org/onap/clamp/util/PassDecoderTest.java | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/test/java/org') diff --git a/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java b/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java index 912e0d604..7762111b0 100644 --- a/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java +++ b/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java @@ -27,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat; import com.google.gson.JsonSyntaxException; import java.io.IOException; +import java.time.Instant; import java.util.List; import javax.transaction.Transactional; @@ -56,10 +57,19 @@ public class PolicyEngineControllerTestItCase { @Transactional public void synchronizeAllPoliciesTest() throws JsonSyntaxException, IOException, InterruptedException { policyController.synchronizeAllPolicies(); + Instant firstExecution = policyController.getLastInstantExecuted(); + assertThat (firstExecution).isNotNull(); List policyModelsList = policyModelsRepository.findAll(); assertThat(policyModelsList.size()).isGreaterThanOrEqualTo(8); assertThat(policyModelsList).contains(new PolicyModel("onap.policies.Monitoring", null, "1.0.0")); assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.Operational", null, "1.0.0")); + + // Re-do it to check that there is no issue with duplicate key + policyController.synchronizeAllPolicies(); + Instant secondExecution = policyController.getLastInstantExecuted(); + assertThat (secondExecution).isNotNull(); + + assertThat(firstExecution).isBefore(secondExecution); } } diff --git a/src/test/java/org/onap/clamp/util/PassDecoderTest.java b/src/test/java/org/onap/clamp/util/PassDecoderTest.java index 56443e31d..e5de8b0a8 100644 --- a/src/test/java/org/onap/clamp/util/PassDecoderTest.java +++ b/src/test/java/org/onap/clamp/util/PassDecoderTest.java @@ -40,13 +40,13 @@ public class PassDecoderTest { @Test public final void testDecryptionNoPassword() throws Exception { - String decodedPass = PassDecoder.decode(null, "src/test/resources/clds/aaf/org.onap.clamp.keyfile"); + String decodedPass = PassDecoder.decode(null, "classpath:clds/aaf/org.onap.clamp.keyfile"); assertNull(decodedPass); } @Test public final void testDecryption() throws Exception { - String decodedPass = PassDecoder.decode(encrypted, "src/test/resources/clds/aaf/org.onap.clamp.keyfile"); + String decodedPass = PassDecoder.decode(encrypted, "classpath:clds/aaf/org.onap.clamp.keyfile"); assertEquals(decodedPass, "China in the Spring"); } } -- cgit 1.2.3-korg