From f88c714f725e952025b9376bf1b3a64afaac8c15 Mon Sep 17 00:00:00 2001 From: Ruchira Agarwal Date: Mon, 26 Mar 2018 22:40:01 +0000 Subject: Add junit for adaptors Added new junits for aai-service Change-Id: Ia717d0e6180f9fd8ecd9d98935d5ceeeaa69530c Issue-ID: CCSDK-225 Signed-off-by: Ruchira Agarwal --- .../sli/adaptors/aai/data/ErrorResponseTest.java | 51 ++++++++++++ .../sli/adaptors/aai/data/RequestErrorTest.java | 51 ++++++++++++ .../sli/adaptors/aai/data/ResponseMessageTest.java | 71 ++++++++++++++++ .../adaptors/aai/data/ResponseMessagesTest.java | 55 +++++++++++++ .../adaptors/aai/data/ServiceExceptionTest.java | 71 ++++++++++++++++ .../sli/adaptors/aai/data/SubInterfaceTest.java | 95 ++++++++++++++++++++++ .../ccsdk/sli/adaptors/aai/data/VariablesTest.java | 56 +++++++++++++ 7 files changed, 450 insertions(+) create mode 100644 aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ErrorResponseTest.java create mode 100644 aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/RequestErrorTest.java create mode 100644 aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ResponseMessageTest.java create mode 100644 aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ResponseMessagesTest.java create mode 100644 aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ServiceExceptionTest.java create mode 100644 aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/SubInterfaceTest.java create mode 100644 aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/VariablesTest.java diff --git a/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ErrorResponseTest.java b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ErrorResponseTest.java new file mode 100644 index 000000000..6232ae34a --- /dev/null +++ b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ErrorResponseTest.java @@ -0,0 +1,51 @@ +package org.onap.ccsdk.sli.adaptors.aai.data; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ErrorResponseTest { + + ErrorResponse _erInstance; + protected RequestError _requestError; + protected Map _additionalProperties; + + @Before + public void setUp() throws Exception { + _erInstance = new ErrorResponse(); + _requestError = mock(RequestError.class); + _additionalProperties = new HashMap() {{ + put("prop1", "propvalue1"); + put("prop2", "propvalue2"); + }}; + } + + @After + public void tearDown() throws Exception { + _erInstance = null; + _requestError = null; + _additionalProperties = null; + } + + @Test + public void testSetRequestError() { + _erInstance.setRequestError(_requestError); + assertEquals(_erInstance.getRequestError(), _requestError); + } + + @Test + public void testSetAdditionalProperty() { + _erInstance.setAdditionalProperty("prop1", "propvalue1"); + _erInstance.setAdditionalProperty("prop2", "propvalue2"); + assertEquals(_erInstance.getAdditionalProperties(), _additionalProperties); + } + +} diff --git a/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/RequestErrorTest.java b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/RequestErrorTest.java new file mode 100644 index 000000000..c752c7656 --- /dev/null +++ b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/RequestErrorTest.java @@ -0,0 +1,51 @@ +package org.onap.ccsdk.sli.adaptors.aai.data; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class RequestErrorTest { + + RequestError _reInstance; + protected ServiceException _serviceException; + protected Map _additionalProperties; + + @Before + public void setUp() throws Exception { + _reInstance = new RequestError(); + _serviceException = mock(ServiceException.class); + _additionalProperties = new HashMap() {{ + put("prop1", "propvalue1"); + put("prop2", "propvalue2"); + }}; + } + + @After + public void tearDown() throws Exception { + _reInstance = null; + _serviceException = null; + _additionalProperties = null; + } + + @Test + public void testSetServiceException() { + _reInstance.setServiceException(_serviceException); + assertEquals(_reInstance.getServiceException(), _serviceException); + } + + @Test + public void testSetAdditionalProperty() { + _reInstance.setAdditionalProperty("prop1", "propvalue1"); + _reInstance.setAdditionalProperty("prop2", "propvalue2"); + assertEquals(_reInstance.getAdditionalProperties(), _additionalProperties); + } + +} diff --git a/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ResponseMessageTest.java b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ResponseMessageTest.java new file mode 100644 index 000000000..04c9963b5 --- /dev/null +++ b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ResponseMessageTest.java @@ -0,0 +1,71 @@ +package org.onap.ccsdk.sli.adaptors.aai.data; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.aai.inventory.v11.Vlans; + +public class ResponseMessageTest { + + ResponseMessage _rmInstance; + protected String _messageId; + protected String _text; + protected Variables _variables; + protected Map _additionalProperties; + + @Before + public void setUp() throws Exception { + _rmInstance = new ResponseMessage(); + _messageId = "messageId"; + _text = "text"; + _variables = mock(Variables.class); + _additionalProperties = new HashMap() {{ + put("prop1", "propvalue1"); + put("prop2", "propvalue2"); + }}; + } + + @After + public void tearDown() throws Exception { + _rmInstance = null; + _messageId = null; + _text = null; + _variables = null; + _additionalProperties = null; + } + + @Test + public void testSetMessageId() { + _rmInstance.setMessageId(_messageId); + assertTrue(_rmInstance.getMessageId().equals(_messageId)); + } + + @Test + public void testSetText() { + _rmInstance.setText(_text); + assertTrue(_rmInstance.getText().equals(_text)); + } + + @Test + public void testSetVariables() { + _rmInstance.setVariables(_variables); + assertEquals(_rmInstance.getVariables(), _variables); + } + + @Test + public void testSetAdditionalProperty() { + _rmInstance.setAdditionalProperty("prop1", "propvalue1"); + _rmInstance.setAdditionalProperty("prop2", "propvalue2"); + assertEquals(_rmInstance.getAdditionalProperties(), _additionalProperties); + } + +} diff --git a/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ResponseMessagesTest.java b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ResponseMessagesTest.java new file mode 100644 index 000000000..f21e969dd --- /dev/null +++ b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ResponseMessagesTest.java @@ -0,0 +1,55 @@ +package org.onap.ccsdk.sli.adaptors.aai.data; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ResponseMessagesTest { + + ResponseMessages _rmsInstance; + protected List _responseMessage; + protected Map _additionalProperties; + + @Before + public void setUp() throws Exception { + _rmsInstance = new ResponseMessages(); + _responseMessage = new ArrayList<>(); + ResponseMessage rm1 = mock(ResponseMessage.class); + ResponseMessage rm2 = mock(ResponseMessage.class); + _responseMessage.add(rm1); + _responseMessage.add(rm2); + _additionalProperties = new HashMap() {{ + put("prop1", "propvalue1"); + put("prop2", "propvalue2"); + }}; + } + + @After + public void tearDown() throws Exception { + _rmsInstance = null; + _responseMessage = null; + _additionalProperties = null; + } + + @Test + public void testSetResponseMessage() { + _rmsInstance.setResponseMessage(_responseMessage); + assertEquals(_rmsInstance.getResponseMessage(), _responseMessage); + } + + @Test + public void testSetAdditionalProperty() { + _rmsInstance.setAdditionalProperty("prop1", "propvalue1"); + _rmsInstance.setAdditionalProperty("prop2", "propvalue2"); + assertEquals(_rmsInstance.getAdditionalProperties(), _additionalProperties); + } + +} diff --git a/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ServiceExceptionTest.java b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ServiceExceptionTest.java new file mode 100644 index 000000000..f44d9b366 --- /dev/null +++ b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/ServiceExceptionTest.java @@ -0,0 +1,71 @@ +package org.onap.ccsdk.sli.adaptors.aai.data; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ServiceExceptionTest { + + ServiceException _seInstance; + protected String _messageId; + protected String _text; + protected List _variables; + protected Map _additionalProperties; + + @Before + public void setUp() throws Exception { + _seInstance = new ServiceException(); + _messageId = "messageId"; + _text = "text"; + _variables = new ArrayList<>(Arrays.asList("var1", "var2", "var3")); + _additionalProperties = new HashMap() {{ + put("prop1", "propvalue1"); + put("prop2", "propvalue2"); + }}; + } + + @After + public void tearDown() throws Exception { + _seInstance = null; + _messageId = null; + _text = null; + _variables = null; + _additionalProperties = null; + } + + @Test + public void testSetMessageId() { + _seInstance.setMessageId(_messageId); + assertTrue(_seInstance.getMessageId().equals(_messageId)); + } + + @Test + public void testSetText() { + _seInstance.setText(_text); + assertTrue(_seInstance.getText().equals(_text)); + } + + @Test + public void testSetVariables() { + _seInstance.setVariables(_variables); + assertEquals(_seInstance.getVariables(), _variables); + } + + @Test + public void testSetAdditionalProperties() { + _seInstance.setAdditionalProperty("prop1", "propvalue1"); + _seInstance.setAdditionalProperty("prop2", "propvalue2"); + assertEquals(_seInstance.getAdditionalProperties(), _additionalProperties); + } + + +} diff --git a/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/SubInterfaceTest.java b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/SubInterfaceTest.java new file mode 100644 index 000000000..66717103d --- /dev/null +++ b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/SubInterfaceTest.java @@ -0,0 +1,95 @@ +package org.onap.ccsdk.sli.adaptors.aai.data; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.aai.inventory.v11.RelationshipList; +import org.openecomp.aai.inventory.v11.Vlans; + +public class SubInterfaceTest { + + SubInterface _siInstance; + protected String _interfaceName; + protected String _interfaceRole; + protected String _resourceVersion; + protected Vlans _vlans; + protected RelationshipList _relationshipList; + protected Map _additionalProperties; + + @Before + public void setUp() throws Exception { + _siInstance = new SubInterface(); + _interfaceName = "interfaceName"; + _interfaceRole = "interfaceRole"; + _resourceVersion = "resourceVersion"; + _vlans = mock(Vlans.class); + _relationshipList = mock(RelationshipList.class); + + _additionalProperties = new HashMap() {{ + put("prop1", "propvalue1"); + put("prop2", "propvalue2"); + }}; + + } + + @After + public void tearDown() throws Exception { + _siInstance = null; + _interfaceName = null; + _interfaceRole = null; + _resourceVersion = null; + _vlans = null; + _relationshipList = null; + _additionalProperties = null; + } + + @Test + public void testSetInterfaceName() { + _siInstance.setInterfaceName(_interfaceName); + assertTrue(_siInstance.getInterfaceName().equals(_interfaceName)); + } + + + @Test + public void testSetInterfaceRole() { + _siInstance.setInterfaceRole(_interfaceRole); + assertTrue(_siInstance.getInterfaceRole().equals(_interfaceRole)); + } + + + @Test + public void testSetResourceVersion() { + _siInstance.setResourceVersion(_resourceVersion); + assertTrue(_siInstance.getResourceVersion().equals(_resourceVersion)); + } + + + @Test + public void testSetVlans() { + _siInstance.setVlans(_vlans); + assertTrue(_siInstance.getVlans().equals(_vlans)); + } + + + @Test + public void testSetRelationshipList() { + _siInstance.setRelationshipList(_relationshipList); + assertTrue(_siInstance.getRelationshipList().equals(_relationshipList)); + } + + @Test + public void testSetAdditionalProperties() { + _siInstance.setAdditionalProperty("prop1", "propvalue1"); + _siInstance.setAdditionalProperty("prop2", "propvalue2"); + assertEquals(_siInstance.getAdditionalProperties(), _additionalProperties); + } + +} diff --git a/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/VariablesTest.java b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/VariablesTest.java new file mode 100644 index 000000000..1f72f7e67 --- /dev/null +++ b/aai-service/provider/src/test/java/org/onap/ccsdk/sli/adaptors/aai/data/VariablesTest.java @@ -0,0 +1,56 @@ +package org.onap.ccsdk.sli.adaptors.aai.data; + +import static org.junit.Assert.*; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import java.util.ArrayList; + +public class VariablesTest { + Variables _variablesInstance; + protected List _variable; + protected Map _additionalProperties; + + public VariablesTest() { + } + + @Before + public void setUp() throws Exception { + _variablesInstance = new Variables(); + _variable = new ArrayList<>(Arrays.asList("var1", "var2", "var3")); + _additionalProperties = new HashMap() {{ + put("prop1", "propvalue1"); + put("prop2", "propvalue2"); + }}; + } + + @After + public void tearDown() throws Exception { + _variablesInstance = null; + _variable = null; + _additionalProperties = null; + } + + + @Test + public void testSetVariable() { + _variablesInstance.setVariable(_variable); + assertEquals(_variablesInstance.getVariable(), _variable); + } + + @Test + public void testSetAdditionalProperties() { + _variablesInstance.setAdditionalProperty("prop1", "propvalue1"); + _variablesInstance.setAdditionalProperty("prop2", "propvalue2"); + assertEquals(_variablesInstance.getAdditionalProperties(), _additionalProperties); + } + +} -- cgit 1.2.3-korg