From 26b7c9ddb2b36b1f6440083811653321aec98fde Mon Sep 17 00:00:00 2001 From: c00149107 Date: Thu, 31 Aug 2017 14:27:38 +0800 Subject: Add VF-C Adapter Add VF-C Adapter to support VF-C APIs Change-Id: I4eb27755c8c5420343f457e0f9be37aa438361eb Issue-ID:SO-41 Signed-off-by: c00149107 --- .../openecomp/mso/adapters/vfc/VfcAdapterTest.java | 146 +++++++++++++++++++++ .../src/test/resources/logback-test.xml | 48 +++++++ 2 files changed, 194 insertions(+) create mode 100644 adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java create mode 100644 adapters/mso-vfc-adapter/src/test/resources/logback-test.xml (limited to 'adapters/mso-vfc-adapter/src/test') 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 new file mode 100644 index 0000000000..3b43a15e50 --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/java/org/openecomp/mso/adapters/vfc/VfcAdapterTest.java @@ -0,0 +1,146 @@ +/*- + * ============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.vfc; + + +import java.io.IOException; + +import org.junit.Test; +import org.mockito.Mock; +import org.openecomp.mso.adapters.vfc.util.RestfulUtil; +import org.openecomp.mso.adapters.vfc.util.ValidateUtil; +import org.openecomp.mso.db.catalog.CatalogDatabase; + +import mockit.MockUp; + +/** + * VF-C adapter UT + *
+ *

+ *

+ * + * @author + * @version ONAP Amsterdam Release 2017-08-31 + */ +public class VfcAdapterTest { + + @Mock + private static CatalogDatabase db; + + /** + * File path + */ + private static final String FILE_PATH = "src/test/resources/json/"; + + @Test + public void createTest () { +// // get request +// mockGetRequestBody(FILE_PATH + "createNfvoNsReq.json"); +// // get service template +// ServiceTemplate svcTmpl = new ServiceTemplate(); +// svcTmpl.setId("id"); +// svcTmpl.setServiceTemplateId("svcTmplId"); +// new MockUp() { +// @Mock +// public ServiceTemplate getSvcTmplByNodeType(String nodeType, String domainHost){ +// return svcTmpl; +// } +// }; +// // get response +// RestfulResponse restRsp = new RestfulResponse(); +// restRsp.setStatus(HttpStatus.SC_OK); +// restRsp.setResponseJson(getJsonString(FILE_PATH + "createNfvoNsRsp.json")); +// mockGetRestfulRsp(restRsp); +// // insert data +// new MockUp() { +// @Mock +// public void insertSegment(ServiceSegmentModel serviceSegment) { +// // do nothing +// } +// @Mock +// public void insertSegmentOper(ServiceSegmentOperation svcSegmentOper) { +// // do nothing +// } +// }; +// Response rsp = impl.createNfvoNs(servletReq); +// JSONObject obj = JSONObject.fromObject(rsp.getEntity()); +// Assert.assertEquals(null, "1", obj.getString("nsInstanceId")); + } + + @Test + public void deleteTest () { + + } + + @Test + public void instantiateTest () { + + } + + @Test + public void terminateTest () { + + } + + @Test + public void queryJobTest () { + + } + + /** + * Mock to get request body.
+ * + * @param file json file path. + * @since GSO 0.5 + */ + private void mockGetRequestBody(final String file) { + new MockUp() { + +// @Mock +// public String getRequestBody(HttpServletRequest request) { +// return getJsonString(file); +// } + }; + } + + /** + * Get json string from file.
+ * + * @param file the path of file + * @return json string + * @throws IOException when fail to read + * @since GSO 0.5 + */ + 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()); +// } + + return json; + } +} diff --git a/adapters/mso-vfc-adapter/src/test/resources/logback-test.xml b/adapters/mso-vfc-adapter/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..26a86877bd --- /dev/null +++ b/adapters/mso-vfc-adapter/src/test/resources/logback-test.xml @@ -0,0 +1,48 @@ + + + + + + + + %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 + + + + + + + + + + + + + + + + + + + + + + -- cgit 1.2.3-korg