summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapters-rest-interface/src/test/java/org
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2018-01-08 18:23:10 +0100
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2018-01-10 15:58:31 +0100
commit2b653795fab53638b62e6eb9c24d6e4add101abf (patch)
tree17c01373590fe1bd15e4e332d71d043c0bab258e /adapters/mso-adapters-rest-interface/src/test/java/org
parent4da1270fb9814f230e064e995bb379db6a4d25d4 (diff)
refactoring - adding junit
Change-Id: I91ba9dafa40df25d1ca1aae5a7dce11e0afb71da Issue-ID: SO-360 Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Diffstat (limited to 'adapters/mso-adapters-rest-interface/src/test/java/org')
-rw-r--r--adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/AdapterRestInterfaceTest.java48
-rw-r--r--adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/BeanTest.java6
-rw-r--r--adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/json/MapSerializerTest.java56
3 files changed, 57 insertions, 53 deletions
diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/AdapterRestInterfaceTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/AdapterRestInterfaceTest.java
deleted file mode 100644
index 00c853ba0d..0000000000
--- a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/AdapterRestInterfaceTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
- * ================================================================================
- * 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.openecomp.mso.adapters;
-
-import java.io.IOException;
-import java.util.HashMap;
-import org.codehaus.jackson.JsonGenerator;
-import org.codehaus.jackson.map.SerializerProvider;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.openecomp.mso.adapters.json.MapSerializer;
-
-public class AdapterRestInterfaceTest {
-
- @Test
- public final void mapSerializerTest() {
- MapSerializer mapSerializer = new MapSerializer();
- mapSerializer.isUnwrappingSerializer();
- mapSerializer.toString();
- mapSerializer.unwrappingSerializer();
- JsonGenerator jsonGenerator = Mockito.mock(JsonGenerator.class);
- SerializerProvider serializerProvider = Mockito
- .mock(SerializerProvider.class);
- try {
- mapSerializer.serialize(new HashMap(), jsonGenerator, serializerProvider);
- } catch (IOException e) {
- }
- }
-
-}
diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/BeanTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/BeanTest.java
index 984ba1b0af..5c3470acd9 100644
--- a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/BeanTest.java
+++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/BeanTest.java
@@ -17,14 +17,12 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.openecomp.mso.test;
+package org.openecomp.mso.adapters;
import java.lang.reflect.Method;
-import java.lang.reflect.Parameter;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
-
import org.junit.Test;
import org.openecomp.mso.adapters.nwrest.ContrailNetwork;
import org.openecomp.mso.adapters.nwrest.CreateNetworkError;
@@ -34,7 +32,6 @@ import org.openecomp.mso.adapters.nwrest.DeleteNetworkError;
import org.openecomp.mso.adapters.nwrest.DeleteNetworkRequest;
import org.openecomp.mso.adapters.nwrest.DeleteNetworkResponse;
import org.openecomp.mso.adapters.nwrest.NetworkExceptionResponse;
-import org.openecomp.mso.adapters.nwrest.NetworkRequestCommon;
import org.openecomp.mso.adapters.nwrest.NetworkTechnology;
import org.openecomp.mso.adapters.nwrest.ProviderVlanNetwork;
import org.openecomp.mso.adapters.nwrest.QueryNetworkResponse;
@@ -74,7 +71,6 @@ import org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupRequest;
import org.openecomp.mso.adapters.vnfrest.UpdateVolumeGroupResponse;
import org.openecomp.mso.adapters.vnfrest.VfModuleExceptionResponse;
import org.openecomp.mso.adapters.vnfrest.VfModuleRollback;
-import org.openecomp.mso.adapters.vnfrest.VfResponseCommon;
import org.openecomp.mso.adapters.vnfrest.VolumeGroupRollback;
import org.openecomp.mso.entity.MsoRequest;
diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/json/MapSerializerTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/json/MapSerializerTest.java
new file mode 100644
index 0000000000..f903f21441
--- /dev/null
+++ b/adapters/mso-adapters-rest-interface/src/test/java/org/openecomp/mso/adapters/json/MapSerializerTest.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.mso.adapters.json;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.junit.Test;
+
+public class MapSerializerTest {
+
+ private static final String JSON_FIELD_NAME_1 = "testKey1";
+ private static final String JSON_VALUE_1 = "testValue1";
+ private static final String JSON_FIELD_NAME_2 = "testKey2";
+ private static final String JSON_VALUE_2 = "testValue2";
+
+ @Test
+ public void serializationWritesTheProperFieldsToJson() throws Exception {
+ JsonGenerator jsonGeneratorMock = mock(JsonGenerator.class);
+ MapSerializer testedObject = new MapSerializer();
+ testedObject.serialize(prepareMap(), jsonGeneratorMock, mock(SerializerProvider.class));
+ verify(jsonGeneratorMock).writeStringField("key", JSON_FIELD_NAME_1);
+ verify(jsonGeneratorMock).writeStringField("value", JSON_VALUE_1);
+ verify(jsonGeneratorMock).writeStringField("key", JSON_FIELD_NAME_2);
+ verify(jsonGeneratorMock).writeStringField("value", JSON_VALUE_2);
+ }
+
+ private Map<String, String> prepareMap() {
+ Map<String, String> map = new HashMap<>();
+ map.put(JSON_FIELD_NAME_1, JSON_VALUE_1);
+ map.put(JSON_FIELD_NAME_2, JSON_VALUE_2);
+ return map;
+ }
+}