add unit test 54/79154/1
authorsonicke <10112215@zte.com.cn>
Tue, 26 Feb 2019 07:27:16 +0000 (15:27 +0800)
committersonicke <10112215@zte.com.cn>
Tue, 26 Feb 2019 07:27:16 +0000 (15:27 +0800)
Issue-ID: VFC-1264

Change-Id: I719d9ce24864ef37f64370cc4ff9dd09c9f6299b
Signed-off-by: Zhuoyao Huang <10112215@zte.com.cn>
12 files changed:
zte/sfc-driver/sfc-driver/src/main/java/org/onap/sfc/entity/MsbRegisterEntity.java
zte/sfc-driver/sfc-driver/src/main/java/org/onap/sfc/entity/NodeEntity.java
zte/sfc-driver/sfc-driver/src/main/java/org/onap/sfc/entity/Result.java
zte/sfc-driver/sfc-driver/src/main/java/org/onap/sfc/entity/SdnControllerInfo.java
zte/sfc-driver/sfc-driver/src/main/java/org/onap/sfc/entity/portpair/PortInfo.java
zte/sfc-driver/sfc-driver/src/main/java/org/onap/sfc/entity/portpair/ServiceFunctionParameter.java
zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/MsbRegisterEntityTest.java [new file with mode: 0644]
zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/NodeEntityTest.java [new file with mode: 0644]
zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/ResultTest.java
zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/SdnControllerInfoTest.java [new file with mode: 0644]
zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/portpair/PortInfoTest.java [new file with mode: 0644]
zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/portpair/ServiceFunctionParameterTest.java [new file with mode: 0644]

index 2946576..6f494c4 100644 (file)
@@ -29,4 +29,11 @@ public class MsbRegisterEntity {
     private String protocol;
     private String visualRange;
     private List<NodeEntity> nodes;
+
+    public boolean equals(Object o) {
+        if(o == this) {
+            return true;
+        }
+        return false;
+    }
 }
index 2e849df..7956166 100644 (file)
@@ -24,4 +24,11 @@ public class NodeEntity {
     private String ip;
     private String port;
     private String ttl;
+
+    public boolean equals(Object o) {
+        if(o == this) {
+            return true;
+        }
+        return false;
+    }
 }
index 96e0ed6..2f7f020 100644 (file)
@@ -26,4 +26,11 @@ public class Result {
         this.id = uuid;
     }
 
+    public boolean equals(Object o) {
+        if(o == this) {
+            return true;
+        }
+        return false;
+    }
+
 }
index 8630095..9910336 100644 (file)
@@ -23,4 +23,11 @@ public class SdnControllerInfo {
     String url;
     String userName;
     String password;
+
+    public boolean equals(Object o) {
+        if(o == this) {
+            return true;
+        }
+        return false;
+    }
 }
index a2f2a9f..31af38f 100644 (file)
@@ -27,4 +27,11 @@ public class PortInfo {
     private String mac;
     @SerializedName("port-name")
     private String portName;
+
+    public boolean equals(Object o) {
+        if(o == this) {
+            return true;
+        }
+        return false;
+    }
 }
index 569a05b..f98c7d9 100644 (file)
@@ -24,4 +24,11 @@ public class ServiceFunctionParameter {
     private String serviceFunctionParamter;
     @SerializedName("service-function-parameter-value")
     private String getServiceFunctionParamterValue;
+
+    public boolean equals(Object o) {
+        if(o == this) {
+            return true;
+        }
+        return false;
+    }
 }
diff --git a/zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/MsbRegisterEntityTest.java b/zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/MsbRegisterEntityTest.java
new file mode 100644 (file)
index 0000000..4a1e024
--- /dev/null
@@ -0,0 +1,77 @@
+package org.onap.sfc.entity;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Copyright 2018 ZTE Corporation.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ */
+public class MsbRegisterEntityTest {
+    MsbRegisterEntity entity1;
+    MsbRegisterEntity entity2;
+    List<NodeEntity> nodes = new ArrayList<>();
+
+
+    @Before
+    public void setUp() throws Exception {
+        entity1 = new MsbRegisterEntity();
+        entity1.setServiceName("serviceName");
+        entity1.setNodes(nodes);
+        entity1.setProtocol("http");
+        entity1.setUrl("http://127.0.0.1");
+        entity1.setVersion("1.0");
+        entity1.setVisualRange("0-6");
+
+        entity2 = new MsbRegisterEntity();
+        entity2.setVisualRange(entity1.getVisualRange());
+        entity2.setVersion(entity1.getVersion());
+        entity2.setUrl(entity1.getUrl());
+        entity2.setServiceName(entity1.getServiceName());
+        entity2.setNodes(entity1.getNodes());
+        entity2.setProtocol(entity1.getProtocol());
+    }
+
+    @Test
+    public void test() throws Exception {
+        assert entity2.getNodes().equals(entity1.getNodes());
+        assert entity2.getProtocol().equals(entity1.getProtocol());
+        assert entity2.getServiceName().equals(entity1.getServiceName());
+        assert entity2.getUrl().equals(entity1.getUrl());
+        assert entity2.getVersion().equals(entity1.getVersion());
+        assert entity2.getVisualRange().equals(entity1.getVisualRange());
+    }
+
+
+    @Test
+    public void equals() throws Exception {
+        assert !entity2.equals(entity1);
+        assert entity2.equals(entity2);
+/*        MsbRegisterEntity entity = new MsbRegisterEntity();
+        assert entity2.equals(entity1);
+        assert entity2.equals(entity2);
+        assert !entity2.equals(null);
+        assert !entity.equals(entity2);
+        assert !entity2.equals(entity);*/
+    }
+
+    @Test
+    public void toStringTest() {
+        assert entity2.toString() != null;
+    }
+
+}
\ No newline at end of file
diff --git a/zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/NodeEntityTest.java b/zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/NodeEntityTest.java
new file mode 100644 (file)
index 0000000..afc2d58
--- /dev/null
@@ -0,0 +1,56 @@
+package org.onap.sfc.entity;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Copyright 2018 ZTE Corporation.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ */
+public class NodeEntityTest {
+    NodeEntity entity1;
+    NodeEntity entity2;
+
+    @Before
+    public void setUp() throws Exception {
+        entity1 = new NodeEntity();
+        entity1.setIp("");
+        entity1.setPort("");
+        entity1.setTtl("");
+
+        entity2 = new NodeEntity();
+        entity2.setIp("");
+        entity2.setPort("");
+        entity2.setTtl("");
+    }
+
+    @Test
+    public void test() throws Exception {
+        assert entity2.getIp().equals(entity1.getIp());
+        assert entity2.getPort().equals(entity1.getPort());
+        assert entity2.getTtl().equals(entity1.getTtl());
+    }
+
+    @Test
+    public void equals() throws Exception {
+        assert !entity2.equals(entity1);
+        assert entity2.equals(entity2);
+    }
+
+    @Test
+    public void toStringTest() throws Exception {
+        assert entity2.toString() != null;
+    }
+
+}
\ No newline at end of file
index 4dc0209..c74424b 100644 (file)
@@ -1,5 +1,6 @@
 package org.onap.sfc.entity;
 
+import org.junit.Before;
 import org.junit.Test;
 
 /**
@@ -18,6 +19,15 @@ import org.junit.Test;
  * limitations under the License.
  */
 public class ResultTest {
+    Result entity1;
+    Result entity2;
+
+    @Before
+    public void setUp() throws Exception {
+        entity1 = new Result("");
+        entity2 = new Result("");
+    }
+
     @Test
     public void getId() throws Exception {
         String uuid = "123";
@@ -25,4 +35,14 @@ public class ResultTest {
         assert result.getId().equals(uuid);
     }
 
+    @Test
+    public void equals() throws Exception {
+        assert !entity2.equals(entity1);
+        assert entity2.equals(entity2);
+    }
+
+    @Test
+    public void toStringTest() throws Exception {
+        assert entity2.toString() != null;
+    }
 }
\ No newline at end of file
diff --git a/zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/SdnControllerInfoTest.java b/zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/SdnControllerInfoTest.java
new file mode 100644 (file)
index 0000000..0937b20
--- /dev/null
@@ -0,0 +1,56 @@
+package org.onap.sfc.entity;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Copyright 2018 ZTE Corporation.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ */
+public class SdnControllerInfoTest {
+    SdnControllerInfo entity1;
+    SdnControllerInfo entity2;
+
+    @Before
+    public void setUp() throws Exception {
+        entity1 = new SdnControllerInfo();
+        entity1.setPassword("");
+        entity1.setUrl("");
+        entity1.setUserName("");
+
+        entity2 = new SdnControllerInfo();
+        entity2.setPassword("");
+        entity2.setUrl("");
+        entity2.setUserName("");
+    }
+
+    @Test
+    public void test() throws Exception {
+        assert entity2.getPassword().equals(entity1.getPassword());
+        assert entity2.getUrl().equals(entity1.getUrl());
+        assert entity2.getUserName().equals(entity1.getUserName());
+    }
+
+    @Test
+    public void equals() throws Exception {
+        assert !entity2.equals(entity1);
+        assert entity2.equals(entity2);
+    }
+
+    @Test
+    public void toStringTest() throws Exception {
+        assert entity2.toString() != null;
+    }
+
+}
\ No newline at end of file
diff --git a/zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/portpair/PortInfoTest.java b/zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/portpair/PortInfoTest.java
new file mode 100644 (file)
index 0000000..7d20b5c
--- /dev/null
@@ -0,0 +1,59 @@
+package org.onap.sfc.entity.portpair;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Copyright 2018 ZTE Corporation.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ */
+public class PortInfoTest {
+    PortInfo portInfo1;
+    PortInfo portInfo2;
+
+    @Before
+    public void setUp() throws Exception {
+        portInfo1 = new PortInfo();
+        portInfo1.setEncapsulation("");
+        portInfo1.setIp("");
+        portInfo1.setMac("");
+        portInfo1.setPortName("");
+
+        portInfo2 = new PortInfo();
+        portInfo2.setEncapsulation("");
+        portInfo2.setIp("");
+        portInfo2.setMac("");
+        portInfo2.setPortName("");
+    }
+
+    @Test
+    public void test() throws Exception {
+        assert portInfo1.getEncapsulation().equals(portInfo2.getEncapsulation());
+        assert portInfo1.getIp().equals(portInfo2.getIp());
+        assert portInfo1.getMac().equals(portInfo2.getMac());
+        assert portInfo1.getPortName().equals(portInfo2.getPortName());
+    }
+
+    @Test
+    public void equals() throws Exception {
+        assert !portInfo2.equals(portInfo1);
+        assert portInfo2.equals(portInfo2);
+    }
+
+    @Test
+    public void toStringTest() throws Exception {
+        assert portInfo2.toString() != null;
+    }
+
+}
\ No newline at end of file
diff --git a/zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/portpair/ServiceFunctionParameterTest.java b/zte/sfc-driver/sfc-driver/src/test/java/org/onap/sfc/entity/portpair/ServiceFunctionParameterTest.java
new file mode 100644 (file)
index 0000000..0a85f7e
--- /dev/null
@@ -0,0 +1,53 @@
+package org.onap.sfc.entity.portpair;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Copyright 2018 ZTE Corporation.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ */
+public class ServiceFunctionParameterTest {
+    ServiceFunctionParameter entity1;
+    ServiceFunctionParameter entity2;
+
+    @Before
+    public void setUp() throws Exception {
+        entity1 = new ServiceFunctionParameter();
+        entity1.setGetServiceFunctionParamterValue("");
+        entity1.setServiceFunctionParamter("");
+
+        entity2 = new ServiceFunctionParameter();
+        entity2.setGetServiceFunctionParamterValue("");
+        entity2.setServiceFunctionParamter("");
+    }
+
+    @Test
+    public void test() throws Exception {
+        assert entity2.getGetServiceFunctionParamterValue().equals(entity1.getGetServiceFunctionParamterValue());
+        assert entity2.getServiceFunctionParamter().equals(entity1.getServiceFunctionParamter());
+    }
+
+    @Test
+    public void equals() throws Exception {
+        assert !entity2.equals(entity1);
+        assert entity2.equals(entity2);
+    }
+
+    @Test
+    public void toStringTest() throws Exception {
+        assert entity2.toString() != null;
+    }
+
+}
\ No newline at end of file