Merge "Add SO VF Module Delete Operation"
[policy/models.git] / models-tosca / src / test / java / org / onap / policy / models / tosca / legacy / concepts / LegacyGuardPolicyTest.java
index d2b2216..e06692a 100644 (file)
 
 package org.onap.policy.models.tosca.legacy.concepts;
 
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 import org.junit.Test;
-import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicy;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
+import org.onap.policy.models.tosca.legacy.concepts.testconcepts.DummyBadLegacyGuardPolicyContent;
 
 public class LegacyGuardPolicyTest {
 
     @Test
     public void test() {
-        LegacyGuardPolicy guard = new LegacyGuardPolicy();
+        LegacyGuardPolicyInput guard = new LegacyGuardPolicyInput();
         assertNotNull(guard);
         guard.setPolicyId("guard.frequency");
         assertEquals("guard.frequency", guard.getPolicyId());
@@ -43,10 +43,12 @@ public class LegacyGuardPolicyTest {
         assertEquals("1", guard.getPolicyVersion());
         Map<String, String> body = new HashMap<>();
         body.put("actor", "SO");
-        List<Map<String, String>> content = new ArrayList<>();
-        content.add(body);
+        LegacyGuardPolicyContent content = new LegacyGuardPolicyContent();
+        content.setActor("SO");
         guard.setContent(content);
-        assertEquals(1, guard.getContent().size());
-    }
+        assertEquals("SO", guard.getContent().getActor());
 
+        DummyBadLegacyGuardPolicyContent dblgpc = new DummyBadLegacyGuardPolicyContent();
+        assertThatThrownBy(dblgpc::getAsPropertyMap).hasMessage("could not convert content to a property map");
+    }
 }