summaryrefslogtreecommitdiffstats
path: root/adapters/mso-vfc-adapter/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-vfc-adapter/src/test')
-rw-r--r--adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java381
-rw-r--r--adapters/mso-vfc-adapter/src/test/resources/logback-test.xml83
2 files changed, 224 insertions, 240 deletions
diff --git a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java
index 4dc8fffdc6..84991d77c8 100644
--- a/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java
+++ b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java
@@ -43,8 +43,7 @@ import mockit.Mock;
import mockit.MockUp;
/**
- * VF-C adapter UT
- * <br>
+ * VF-C adapter UT <br>
* <p>
* </p>
*
@@ -53,200 +52,194 @@ import mockit.MockUp;
*/
public class VfcAdapterTest {
- private VfcAdapterRest vfcAdapter = new VfcAdapterRest();
-
- /**
- * File path
- */
- private static final String FILE_PATH = "src/test/resources/json/";
-
- /**
- * Mock the request body form a file
- * <br>
- *
- * @param fileName
- * @since ONAP Amsterdam Release
- */
- private void mockRestfulUtil(String fileName) {
- new MockUp<RestfulUtil>() {
-
- /**
- * mock get request body
- * <br>
- *
- * @param request
- * @return
- * @since ONAP Amsterdam Release
- */
- @Mock
- public String getRequestBody(HttpServletRequest request) {
- return getJsonString(fileName);
- }
-
- /**
- * mock get send method
- * <br>
- *
- * @param url
- * @param methodType
- * @param content
- * @return
- * @since ONAP Amsterdam Release
- */
- @Mock
- public RestfulResponse send(String url, String methodType, String content) {
- if(url.equals(CommonConstant.NFVO_CREATE_URL) && methodType.equals(CommonConstant.MethodType.POST)) {
- return getResponse("createNsRsp.json");
- } else if(url.contains("instantiate") && methodType.equals(CommonConstant.MethodType.POST)) {
- return getResponse("instantiateNsRsp.json");
- } else if(methodType.equals(CommonConstant.MethodType.DELETE)) {
- return getResponse(null);
- } else if(url.contains("terminate") && methodType.equals(CommonConstant.MethodType.POST)) {
- return getResponse("terminateNsRsp.json");
- } else if(url.contains("/api/nslcm/v1/jobs") && methodType.equals(CommonConstant.MethodType.GET)) {
- return getResponse("queryJobRsp.json");
- }
- else {
- return null;
- }
- }
- };
- }
-
- /**
- * Mock the request body form a file
- * <br>
- *
- * @param fileName
- * @since ONAP Amsterdam Release
- */
- private void mockRequestDatabase() {
- new MockUp<RequestsDatabase>() {
-
- /**
- * mock get resource operation status
- * <br>
- *
- * @param request
- * @return
- * @since ONAP Amsterdam Release
- */
- @Mock
- public ResourceOperationStatus getResourceOperationStatus(String serviceId, String operationId,
- String resourceTemplateUUID) {
- ResourceOperationStatus resStatus = new ResourceOperationStatus();
- resStatus.setServiceId("111");
- resStatus.setOperationId("111");
- return resStatus;
- }
-
- /**
- * Mock update Res Oper Status
- * <br>
- *
- * @param operStatus
- * @since ONAP Amsterdam Release
- */
- @Mock
- public void updateResOperStatus(ResourceOperationStatus operStatus) {
-
- }
- };
- }
-
- /**
- * Before executing UT, start mock requst database
- * <br>
- *
- * @since ONAP Amsterdam Release
- */
- @Before
- public void start() {
- mockRequestDatabase();
- }
-
- /**
- * After executing UT, close session<br/>
- *
- * @since ONAP Amsterdam Release
- */
- @After
- public void stop() {
-
- }
-
- @Test
- public void createTest() {
- // get request
- mockRestfulUtil(FILE_PATH + "createNsReq.json");
- vfcAdapter.createNfvoNs(null);
- }
-
- @Test
- public void deleteTest() {
- // get request
- mockRestfulUtil(FILE_PATH + "deleteNsReq.json");
- vfcAdapter.deleteNfvoNs(null, "9b9f02c0-298b-458a-bc9c-be3692e4f354");
- }
-
- @Test
- public void instantiateTest() {
- // get request
- mockRestfulUtil(FILE_PATH + "instantiateNsReq.json");
- vfcAdapter.instantiateNfvoNs(null, "9b9f02c0-298b-458a-bc9c-be3692e4f354");
- }
-
- @Test
- public void terminateTest() {
- mockRestfulUtil(FILE_PATH + "terminateNsReq.json");
- vfcAdapter.terminateNfvoNs(null, "9b9f02c0-298b-458a-bc9c-be3692e4f354");
- }
-
- @Test
- public void queryJobTest() {
- mockRestfulUtil(FILE_PATH + "queryJobReq.json");
- vfcAdapter.queryNfvoJobStatus(null, "1");
- }
-
- /**
- * Get json string from file.<br/>
- *
- * @param file the path of file
- * @return json string
- * @throws IOException when fail to read
- * @since ONAP Amsterdam Release 2017-9-6
- */
- @SuppressWarnings("deprecation")
- private String getJsonString(final String file) {
- if(ValidateUtil.isStrEmpty(file)) {
- return "";
- }
-
- String json = null;
- try {
- FileInputStream fileStream = new FileInputStream(new File(file));
- json = IOUtils.toString(fileStream);
- } catch(Exception e) {
- Assert.fail(e.getMessage());
+ private VfcAdapterRest vfcAdapter = new VfcAdapterRest();
+
+ /**
+ * File path
+ */
+ private static final String FILE_PATH = "src/test/resources/json/";
+
+ /**
+ * Mock the request body form a file <br>
+ *
+ * @param fileName
+ * @since ONAP Amsterdam Release
+ */
+ private void mockRestfulUtil(String fileName) {
+ new MockUp<RestfulUtil>() {
+
+ /**
+ * mock get request body <br>
+ *
+ * @param request
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ @Mock
+ public String getRequestBody(HttpServletRequest request) {
+ return getJsonString(fileName);
+ }
+
+ /**
+ * mock get send method <br>
+ *
+ * @param url
+ * @param methodType
+ * @param content
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ @Mock
+ public RestfulResponse send(String url, String methodType, String content) {
+ if (url.equals(CommonConstant.NFVO_CREATE_URL)
+ && methodType.equals(CommonConstant.MethodType.POST)) {
+ return getResponse("createNsRsp.json");
+ } else if (url.contains("instantiate")
+ && methodType.equals(CommonConstant.MethodType.POST)) {
+ return getResponse("instantiateNsRsp.json");
+ } else if (methodType.equals(CommonConstant.MethodType.DELETE)) {
+ return getResponse(null);
+ } else if (url.contains("terminate") && methodType.equals(CommonConstant.MethodType.POST)) {
+ return getResponse("terminateNsRsp.json");
+ } else if (url.contains("/api/nslcm/v1/jobs")
+ && methodType.equals(CommonConstant.MethodType.GET)) {
+ return getResponse("queryJobRsp.json");
+ } else {
+ return null;
}
- return json;
+ }
+ };
+ }
+
+ /**
+ * Mock the request body form a file <br>
+ *
+ * @param fileName
+ * @since ONAP Amsterdam Release
+ */
+ private void mockRequestDatabase() {
+ new MockUp<RequestsDatabase>() {
+
+ /**
+ * mock get resource operation status <br>
+ *
+ * @param request
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ @Mock
+ public ResourceOperationStatus getResourceOperationStatus(String serviceId,
+ String operationId, String resourceTemplateUUID) {
+ ResourceOperationStatus resStatus = new ResourceOperationStatus();
+ resStatus.setServiceId("111");
+ resStatus.setOperationId("111");
+ return resStatus;
+ }
+
+ /**
+ * Mock update Res Oper Status <br>
+ *
+ * @param operStatus
+ * @since ONAP Amsterdam Release
+ */
+ @Mock
+ public void updateResOperStatus(ResourceOperationStatus operStatus) {
+
+ }
+ };
+ }
+
+ /**
+ * Before executing UT, start mock requst database <br>
+ *
+ * @since ONAP Amsterdam Release
+ */
+ @Before
+ public void start() {
+ mockRequestDatabase();
+ }
+
+ /**
+ * After executing UT, close session<br/>
+ *
+ * @since ONAP Amsterdam Release
+ */
+ @After
+ public void stop() {
+
+ }
+
+ @Test
+ public void createTest() {
+ // get request
+ mockRestfulUtil(FILE_PATH + "createNsReq.json");
+ vfcAdapter.createNfvoNs(null);
+ }
+
+ @Test
+ public void deleteTest() {
+ // get request
+ mockRestfulUtil(FILE_PATH + "deleteNsReq.json");
+ vfcAdapter.deleteNfvoNs(null, "9b9f02c0-298b-458a-bc9c-be3692e4f354");
+ }
+
+ @Test
+ public void instantiateTest() {
+ // get request
+ mockRestfulUtil(FILE_PATH + "instantiateNsReq.json");
+ vfcAdapter.instantiateNfvoNs(null, "9b9f02c0-298b-458a-bc9c-be3692e4f354");
+ }
+
+ @Test
+ public void terminateTest() {
+ mockRestfulUtil(FILE_PATH + "terminateNsReq.json");
+ vfcAdapter.terminateNfvoNs(null, "9b9f02c0-298b-458a-bc9c-be3692e4f354");
+ }
+
+ @Test
+ public void queryJobTest() {
+ mockRestfulUtil(FILE_PATH + "queryJobReq.json");
+ vfcAdapter.queryNfvoJobStatus(null, "1");
+ }
+
+ /**
+ * Get json string from file.<br/>
+ *
+ * @param file the path of file
+ * @return json string
+ * @throws IOException when fail to read
+ * @since ONAP Amsterdam Release 2017-9-6
+ */
+ @SuppressWarnings("deprecation")
+ private String getJsonString(final String file) {
+ if (ValidateUtil.isStrEmpty(file)) {
+ return "";
}
- /**
- * get the response from file
- * <br>
- *
- * @param fileName
- * @return
- * @since ONAP Amsterdam Release
- */
- private RestfulResponse getResponse(String fileName) {
- RestfulResponse responseSuccess = new RestfulResponse();
- responseSuccess.setStatus(HttpCode.RESPOND_OK);
- if(null != fileName) {
- String jsonStr = getJsonString(FILE_PATH + fileName);
- responseSuccess.setResponseContent(jsonStr);
- }
- return responseSuccess;
+ String json = null;
+ try {
+ FileInputStream fileStream = new FileInputStream(new File(file));
+ json = IOUtils.toString(fileStream);
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ return json;
+ }
+
+ /**
+ * get the response from file <br>
+ *
+ * @param fileName
+ * @return
+ * @since ONAP Amsterdam Release
+ */
+ private RestfulResponse getResponse(String fileName) {
+ RestfulResponse responseSuccess = new RestfulResponse();
+ responseSuccess.setStatus(HttpCode.RESPOND_OK);
+ if (null != fileName) {
+ String jsonStr = getJsonString(FILE_PATH + fileName);
+ responseSuccess.setResponseContent(jsonStr);
}
+ return responseSuccess;
+ }
}
diff --git a/adapters/mso-vfc-adapter/src/test/resources/logback-test.xml b/adapters/mso-vfc-adapter/src/test/resources/logback-test.xml
index 26a86877bd..61d9c45543 100644
--- a/adapters/mso-vfc-adapter/src/test/resources/logback-test.xml
+++ b/adapters/mso-vfc-adapter/src/test/resources/logback-test.xml
@@ -1,48 +1,39 @@
-<!--
- ============LICENSE_START=======================================================
- ONAP SO
- ================================================================================
- Copyright (C) 2017 Huawei Intellectual Property. 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=========================================================
- -->
-
-<configuration >
-
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern>
- </encoder>
- </appender>
-
-
- <logger name="com.att.eelf.audit" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="com.att.eelf.metrics" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="com.att.eelf.error" level="trace" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <root level="info">
- <appender-ref ref="STDOUT" />
- </root>
-
+<!-- ============LICENSE_START=======================================================
+ ONAP SO ================================================================================
+ Copyright (C) 2017 Huawei Intellectual Property. 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========================================================= -->
+
+<configuration>
+
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern>
+ </encoder>
+ </appender>
+
+
+ <logger name="com.att.eelf.audit" level="info" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="com.att.eelf.metrics" level="info" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <logger name="com.att.eelf.error" level="trace" additivity="false">
+ <appender-ref ref="STDOUT" />
+ </logger>
+
+ <root level="info">
+ <appender-ref ref="STDOUT" />
+ </root>
+
</configuration>