add unit test 69/16569/1
authorShiwei Tian <tian.shiwei@zte.com.cn>
Fri, 29 Sep 2017 03:17:15 +0000 (11:17 +0800)
committerShiwei Tian <tian.shiwei@zte.com.cn>
Fri, 29 Sep 2017 03:17:15 +0000 (11:17 +0800)
Issue-ID: HOLMES-44

Change-Id: Iddb310ad9aa265e9c23b6bc50a097a3301c40acb
Signed-off-by: Shiwei Tian <tian.shiwei@zte.com.cn>
holmes-actions/src/test/java/org/onap/holmes/common/aai/config/AaiConfigTest.java [new file with mode: 0644]
holmes-actions/src/test/java/org/onap/holmes/common/aai/entity/RelationshipListTest.java [new file with mode: 0644]
holmes-actions/src/test/java/org/onap/holmes/common/aai/entity/VmEntityTest.java [new file with mode: 0644]
holmes-actions/src/test/java/org/onap/holmes/common/aai/entity/VmResourceLinkTest.java [new file with mode: 0644]
holmes-actions/src/test/java/org/onap/holmes/common/aai/entity/VnfEntityTest.java [new file with mode: 0644]
holmes-actions/src/test/java/org/onap/holmes/common/api/stat/AlarmAdditionalFieldTest.java [new file with mode: 0644]

diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/aai/config/AaiConfigTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/aai/config/AaiConfigTest.java
new file mode 100644 (file)
index 0000000..bc91f43
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.aai.config;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class AaiConfigTest {
+
+    @Test
+    public void testAaiConfig_get_static_fields() {
+        String aaiVnfAddr = "/aai/v11/network/generic-vnfs/generic-vnf?";
+        String aaiVmAddr = "/aai/v11/search/nodes-query?search-node-type=vserver&filter=";
+        String xTransactionId = "9999";
+        String xFromAppId = "jimmy-postman";
+        assertThat(aaiVnfAddr, equalTo(AaiConfig.AAI_VNF_ADDR));
+        assertThat(aaiVmAddr, equalTo(AaiConfig.AAI_VM_ADDR));
+        assertThat(xTransactionId, equalTo(AaiConfig.X_TRANSACTION_ID));
+        assertThat(xFromAppId, equalTo(AaiConfig.X_FROMAPP_ID));
+    }
+
+    @Test
+    public void testAaiConfig_getAuthenticationCredentials() {
+        String expect = "Basic QUFJOkFBSQ==";
+        assertThat(expect, equalTo(AaiConfig.getAuthenticationCredentials()));
+    }
+}
\ No newline at end of file
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/aai/entity/RelationshipListTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/aai/entity/RelationshipListTest.java
new file mode 100644 (file)
index 0000000..5d7c32e
--- /dev/null
@@ -0,0 +1,88 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.aai.entity;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.holmes.common.aai.entity.RelationshipList.RelatedToProperty;
+import org.onap.holmes.common.aai.entity.RelationshipList.Relationship;
+import org.onap.holmes.common.aai.entity.RelationshipList.RelationshipData;
+
+public class RelationshipListTest {
+
+    private RelationshipList relationshipList;
+
+    @Before
+    public void serUp() {
+        relationshipList = new RelationshipList();
+    }
+
+    @Test
+    public void testRelationShip_getter_setter() {
+        List<RelatedToProperty> relatedToPropertyList = new ArrayList<>();
+        RelatedToProperty relatedToProperty = new RelatedToProperty();
+        String propertyKey = "properKey";
+        String propertyValue = "propertyValue";
+        relatedToProperty.setPropertyKey(propertyKey);
+        relatedToProperty.setPropertyValue(propertyValue);
+        relatedToPropertyList.add(relatedToProperty);
+
+        List<RelationshipData> relationshipDataList = new ArrayList<>();
+        RelationshipData relationshipData = new RelationshipData();
+        String relationshipKey = "relationshipKey";
+        String relationshipValue = "relationshipValue";
+        relationshipData.setRelationshipKey(relationshipKey);
+        relationshipData.setRelationshipValue(relationshipValue);
+        relationshipDataList.add(relationshipData);
+
+        List<Relationship> relationships = new ArrayList<>();
+        Relationship relationship = new Relationship();
+        String relatedLink = "relatedLink";
+        String relatedTo = "relatedTo";
+        relationship.setRelatedLink(relatedLink);
+        relationship.setRelatedTo(relatedTo);
+        relationship.setRelatedToPropertyList(relatedToPropertyList);
+        relationship.setRelationshipDataList(relationshipDataList);
+        relationships.add(relationship);
+
+        relationshipList.setRelationships(relationships);
+        assertThat(1, equalTo(relationshipList.getRelationships().size()));
+        assertThat(relatedLink,
+                equalTo(relationshipList.getRelationships().get(0).getRelatedLink()));
+        assertThat(relatedTo, equalTo(relationshipList.getRelationships().get(0).getRelatedTo()));
+        assertThat(1, equalTo(relationshipList.getRelationships().get(0).getRelatedToPropertyList()
+                .size()));
+        assertThat(propertyKey,
+                equalTo(relationshipList.getRelationships().get(0).getRelatedToPropertyList().get(0)
+                        .getPropertyKey()));
+        assertThat(propertyValue,
+                equalTo(relationshipList.getRelationships().get(0).getRelatedToPropertyList().get(0)
+                        .getPropertyValue()));
+        assertThat(1, equalTo(relationshipList.getRelationships().get(0).getRelationshipDataList()
+                .size()));
+        assertThat(relationshipKey,
+                equalTo(relationshipList.getRelationships().get(0).getRelationshipDataList().get(0)
+                        .getRelationshipKey()));
+        assertThat(relationshipValue,
+                equalTo(relationshipList.getRelationships().get(0).getRelationshipDataList().get(0)
+                        .getRelationshipValue()));
+    }
+}
\ No newline at end of file
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/aai/entity/VmEntityTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/aai/entity/VmEntityTest.java
new file mode 100644 (file)
index 0000000..8c34031
--- /dev/null
@@ -0,0 +1,61 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.aai.entity;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class VmEntityTest {
+
+    private VmEntity vmEntity;
+
+    @Before
+    public void setUp() {
+        vmEntity = new VmEntity();
+    }
+
+    @Test
+    public void testVmEntityTest_getter_setter() {
+        boolean inMaint = false;
+        boolean closedLoopDisabled = true;
+        String provStatus = "world";
+        String resourceVersion = "seldsw";
+        String vserverId = "versio";
+        String vserverName = "12345";
+        String vserverName2 = "lllss";
+        String vserverSelflink = "qwertt";
+        vmEntity.setInMaint(inMaint);
+        vmEntity.setClosedLoopDisable(closedLoopDisabled);
+        vmEntity.setProvStatus(provStatus);
+        vmEntity.setResourceVersion(resourceVersion);
+        vmEntity.setVserverId(vserverId);
+        vmEntity.setVserverName(vserverName);
+        vmEntity.setVserverName2(vserverName2);
+        vmEntity.setVserverSelflink(vserverSelflink);
+        assertThat(inMaint, equalTo(vmEntity.getInMaint()));
+        assertThat(closedLoopDisabled, equalTo(vmEntity.getClosedLoopDisable()));
+        assertThat(provStatus, equalTo(vmEntity.getProvStatus()));
+        assertThat(resourceVersion, equalTo(vmEntity.getResourceVersion()));
+        assertThat(vserverId, equalTo(vmEntity.getVserverId()));
+        assertThat(vserverName, equalTo(vmEntity.getVserverName()));
+        assertThat(vserverName2, equalTo(vmEntity.getVserverName2()));
+        assertThat(vserverSelflink, equalTo(vmEntity.getVserverSelflink()));
+        assertThat(true, equalTo(vmEntity.getRelationshipList() != null));
+    }
+}
\ No newline at end of file
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/aai/entity/VmResourceLinkTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/aai/entity/VmResourceLinkTest.java
new file mode 100644 (file)
index 0000000..59cca7d
--- /dev/null
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.aai.entity;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class VmResourceLinkTest {
+
+    private VmResourceLink vmResourceLink;
+
+    @Before
+    public void setUp() {
+        vmResourceLink = new VmResourceLink();
+    }
+
+    @Test
+    public void getterAndSetter_resourceLink() {
+        String resourceLink = "test";
+        vmResourceLink.setResourceLink(resourceLink);
+        assertThat(resourceLink, equalTo(vmResourceLink.getResourceLink()));
+    }
+
+    @Test
+    public void getterAndSetter_resourceType() {
+        String resourceType = "test1";
+        vmResourceLink.setResourceType("test1");
+        assertThat(resourceType, equalTo(vmResourceLink.getResourceType()));
+    }
+}
\ No newline at end of file
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/aai/entity/VnfEntityTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/aai/entity/VnfEntityTest.java
new file mode 100644 (file)
index 0000000..fa02973
--- /dev/null
@@ -0,0 +1,64 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.aai.entity;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class VnfEntityTest {
+
+    private VnfEntity vnfEntity;
+
+    @Before
+    public void setUp() {
+        vnfEntity = new VnfEntity();
+    }
+
+    @Test
+    public void testVnfEntity_getter_setter() {
+        boolean inMaint = false;
+        boolean closedLoopDisabled = true;
+        String orchestrationStatus = "hello";
+        String provStatus = "world";
+        String resourceVersion = "seldsw";
+        String serviceId = "versio";
+        String vnfId = "12345";
+        String vnfName = "lllss";
+        String vnfType = "qwertt";
+        vnfEntity.setInMaint(inMaint);
+        vnfEntity.setClosedLoopDisabled(closedLoopDisabled);
+        vnfEntity.setOrchestrationStatus(orchestrationStatus);
+        vnfEntity.setProvStatus(provStatus);
+        vnfEntity.setResourceVersion(resourceVersion);
+        vnfEntity.setServiceId(serviceId);
+        vnfEntity.setVnfId(vnfId);
+        vnfEntity.setVnfName(vnfName);
+        vnfEntity.setVnfType(vnfType);
+        assertThat(inMaint, equalTo(vnfEntity.getInMaint()));
+        assertThat(closedLoopDisabled, equalTo(vnfEntity.getClosedLoopDisabled()));
+        assertThat(orchestrationStatus, equalTo(vnfEntity.getOrchestrationStatus()));
+        assertThat(provStatus, equalTo(vnfEntity.getProvStatus()));
+        assertThat(resourceVersion, equalTo(vnfEntity.getResourceVersion()));
+        assertThat(serviceId, equalTo(vnfEntity.getServiceId()));
+        assertThat(vnfId, equalTo(vnfEntity.getVnfId()));
+        assertThat(vnfName, equalTo(vnfEntity.getVnfName()));
+        assertThat(vnfType, equalTo(vnfEntity.getVnfType()));
+        assertThat(true, equalTo(vnfEntity.getRelationshipList() != null));
+    }
+}
\ No newline at end of file
diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/api/stat/AlarmAdditionalFieldTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/api/stat/AlarmAdditionalFieldTest.java
new file mode 100644 (file)
index 0000000..9dd5d94
--- /dev/null
@@ -0,0 +1,46 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.holmes.common.api.stat;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class AlarmAdditionalFieldTest {
+
+    private AlarmAdditionalField alarmAdditionalField;
+
+    @Before
+    public void setUp() {
+        alarmAdditionalField = new AlarmAdditionalField();
+    }
+
+    @Test
+    public void getterAndSetterName() {
+        String name = "test";
+        alarmAdditionalField.setName(name);
+        assertThat(name, equalTo(alarmAdditionalField.getName()));
+    }
+
+    @Test
+    public void getterAndSetterValue() {
+        String value = "tset1";
+        alarmAdditionalField.setValue(value);
+        assertThat(value, equalTo(alarmAdditionalField.getValue()));
+    }
+}
\ No newline at end of file