diff options
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace/src/test/java')
14 files changed, 615 insertions, 0 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfigTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfigTest.java new file mode 100644 index 00000000..cd74b4aa --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/common/HttpServerPathConfigTest.java @@ -0,0 +1,35 @@ +/** + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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. + */ +package org.onap.vnfsdk.marketplace.common; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class HttpServerPathConfigTest { + + @Before + public void setUp() throws Exception { + + } + @Test + public void testGetterSetter() + { + HttpServerPathConfig.setHttpServerPath("csi"); + assertEquals(HttpServerPathConfig.getHttpServerPath(),"csi"); + } +}
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/common/MarketplaceResourceTypeTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/common/MarketplaceResourceTypeTest.java new file mode 100644 index 00000000..24c20eb1 --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/common/MarketplaceResourceTypeTest.java @@ -0,0 +1,28 @@ +/** + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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. + */ +package org.onap.vnfsdk.marketplace.db.common; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class MarketplaceResourceTypeTest { + @Test + public void testEnum() { + MarketplaceResourceType.getType("SERVICETEMPLATE"); + } + +}
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeExceptionTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeExceptionTest.java new file mode 100644 index 00000000..01bd7c31 --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/exception/ErrorCodeExceptionTest.java @@ -0,0 +1,42 @@ +/** + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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. + */ +package org.onap.vnfsdk.marketplace.db.exception; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ErrorCodeExceptionTest { + ErrorCodeException e1; + + @Before + public void setUp() { + e1 = new ErrorCodeException(null, 0, 0, null, null); + } + + @Test + public void testConstructor() { + + ErrorCodeException e2 = new ErrorCodeException(0, null); + + } + + @Test + public void testGet() { + e1.getErrorCode(); + } +}
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/exception/MarketplaceResourceExceptionTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/exception/MarketplaceResourceExceptionTest.java new file mode 100644 index 00000000..df386060 --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/db/exception/MarketplaceResourceExceptionTest.java @@ -0,0 +1,34 @@ +/** + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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. + */ +package org.onap.vnfsdk.marketplace.db.exception; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class MarketplaceResourceExceptionTest { + MarketplaceResourceException marketplaceResourceException; + @Before + public void setUp() throws Exception { + marketplaceResourceException= new MarketplaceResourceException(null,0,0,null,null); + } + @Test + public void testGetter() + { + marketplaceResourceException.getErrcode(); + } +}
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbDetailsTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbDetailsTest.java new file mode 100644 index 00000000..a1544778 --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbDetailsTest.java @@ -0,0 +1,30 @@ +/** + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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. + */ +package org.onap.vnfsdk.marketplace.msb; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class MsbDetailsTest { + MsbDetails msbDetails=new MsbDetails(); + @Test + public void testGetDefaultServer() + { + msbDetails.getDefaultServer(); + } + +}
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbServerTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbServerTest.java new file mode 100644 index 00000000..cac8557e --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/msb/MsbServerTest.java @@ -0,0 +1,37 @@ +/** + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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. + */ +package org.onap.vnfsdk.marketplace.msb; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class MsbServerTest { + MsbServer msbServer; + @Before + public void setUp() throws Exception { + msbServer= new MsbServer(); + } + @Test + public void testSetterGetter() + { + msbServer.setHost("csi"); + assertEquals(msbServer.getHost(),"csi"); + msbServer.setPort("123"); + assertEquals(msbServer.getPort(),"123"); + } +}
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestExceutorTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestExceutorTest.java new file mode 100644 index 00000000..dbcdfd9c --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/functiontest/FunctionTestExceutorTest.java @@ -0,0 +1,65 @@ +/** + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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. + */ +package org.onap.vnfsdk.marketplace.onboarding.hooks.functiontest; + +import mockit.Mock; +import mockit.MockUp; +import org.junit.Before; +import org.junit.Test; +import org.onap.vnfsdk.marketplace.common.FileUtil; +import org.onap.vnfsdk.marketplace.msb.MsbDetails; +import org.onap.vnfsdk.marketplace.msb.MsbDetailsHolder; +import org.onap.vnfsdk.marketplace.onboarding.entity.OnBoradingRequest; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; + +public class FunctionTestExceutorTest { + FunctionTestExceutor functionTestExceutor; + OnBoradingRequest onBoradingRequest; + MsbDetails msbDetails; + + @Before + public void setUp() throws Exception { + onBoradingRequest = mock(OnBoradingRequest.class); + msbDetails = mock(MsbDetails.class); + } + + @Test + public void testExecFunctionTest() { + new MockUp<FileUtil>() { + @Mock + public boolean validatePath(String path) { + return true; + } + }; + FunctionTestExceutor.execFunctionTest(onBoradingRequest); + + } + + @Test + public void testExecFunctionTest2() { + new MockUp<MsbDetailsHolder>() { + @Mock + public MsbDetails getMsbDetails() { + return msbDetails; + } + }; + FunctionTestExceutor.execFunctionTest(onBoradingRequest); + + } + +}
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifeCycleTestReqTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifeCycleTestReqTest.java new file mode 100644 index 00000000..bcbfcf29 --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifeCycleTestReqTest.java @@ -0,0 +1,40 @@ +/** + * Copyright 2018 Huawei Technologies Co., Ltd. + * + * 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. + */ +package org.onap.vnfsdk.marketplace.onboarding.hooks.validatelifecycle; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class LifeCycleTestReqTest { + LifeCycleTestReq lifeCycleTestReq; + @Before + public void setUp() throws Exception { + lifeCycleTestReq= new LifeCycleTestReq(); + } + + @Test + public void testEstterGetter() + { + lifeCycleTestReq.setCsarId("csi"); + assertEquals(lifeCycleTestReq.getCsarId(),"csi"); + lifeCycleTestReq.setLabVimId("csi"); + assertEquals(lifeCycleTestReq.getLabVimId(),"csi"); + lifeCycleTestReq.setVimIds(null); + assertEquals(lifeCycleTestReq.getVimIds(),null); + } +}
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutorTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutorTest.java new file mode 100644 index 00000000..04180322 --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestExceutorTest.java @@ -0,0 +1,49 @@ +/** + * Copyright 2018 Huawei Technologies Co., Ltd. + * + * 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. + */ +package org.onap.vnfsdk.marketplace.onboarding.hooks.validatelifecycle; + +import org.junit.Before; +import org.junit.Test; +import org.onap.vnfsdk.marketplace.onboarding.entity.OnBoradingRequest; + +import static org.mockito.Mockito.mock; + +public class LifecycleTestExceutorTest { + private LifecycleTestExceutor lifecycleTestExceutor; + private OnBoradingRequest onBoradingRequest; + LifeCycleTestReq lifeCycleTestReq; + @Before + public void setUp() + { + // lifecycleTestExceutor = new LifecycleTestExceutor(); + onBoradingRequest = mock(OnBoradingRequest.class); + lifeCycleTestReq = mock(LifeCycleTestReq.class); + } + + @Test + public void testupLoadPackageToCatalouge() + { + // LifecycleTestExceutor.uploadPackageToCatalouge(onBoradingRequest); + } + @Test + public void testExeclifecycleTest() + { + LifecycleTestExceutor.execlifecycleTest(onBoradingRequest,lifeCycleTestReq); + + } + + +}
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHookTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHookTest.java new file mode 100644 index 00000000..64dc19ca --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/LifecycleTestHookTest.java @@ -0,0 +1,40 @@ +/** + * Copyright 2018 Huawei Technologies Co., Ltd. + * + * 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. + */ +package org.onap.vnfsdk.marketplace.onboarding.hooks.validatelifecycle; + +import org.junit.Before; +import org.junit.Test; +import org.onap.vnfsdk.marketplace.onboarding.entity.OnBoradingRequest; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; + +public class LifecycleTestHookTest { + + LifecycleTestHook lifecycleTestHook; + OnBoradingRequest onBoradingRequest; + @Before + public void setUp() throws Exception { + lifecycleTestHook= new LifecycleTestHook(); + onBoradingRequest = mock(OnBoradingRequest.class); + } + @Test + public void testExec() + { + // lifecycleTestHook.exec(onBoradingRequest); + + } +}
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponseTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponseTest.java new file mode 100644 index 00000000..b6629ccf --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/hooks/validatelifecycle/ValidateLifecycleTestResponseTest.java @@ -0,0 +1,40 @@ +/** + * Copyright 2018 Huawei Technologies Co., Ltd. + * + * 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. + */ +package org.onap.vnfsdk.marketplace.onboarding.hooks.validatelifecycle; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ValidateLifecycleTestResponseTest { + + ValidateLifecycleTestResponse validateLifecycleTestResponse; + @Before + public void setUp() throws Exception { + validateLifecycleTestResponse= new ValidateLifecycleTestResponse(); + } + @Test + public void testSetterGetter() + { + validateLifecycleTestResponse.setJobId("huawei"); + assertEquals(validateLifecycleTestResponse.getJobId(),"huawei"); + validateLifecycleTestResponse.setLifecycle_status("huawei"); + assertEquals(validateLifecycleTestResponse.getLifecycle_status(),"huawei"); + validateLifecycleTestResponse.setValidate_status("huawei"); + assertEquals(validateLifecycleTestResponse.getValidate_status(),"huawei"); + } +}
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandlerTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandlerTest.java new file mode 100644 index 00000000..9377e367 --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/onboarding/onboardmanager/OnBoardingHandlerTest.java @@ -0,0 +1,52 @@ +/** + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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. + */ + + +package org.onap.vnfsdk.marketplace.onboarding.onboardmanager; + +import org.junit.Before; +import org.junit.Test; +import org.onap.vnfsdk.marketplace.onboarding.entity.OnBoradingRequest; +import org.onap.vnfsdk.marketplace.onboarding.hooks.validatelifecycle.LifecycleTestHook; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class OnBoardingHandlerTest { + private OnBoradingRequest onBoardingReq; + private OnBoardingHandler onboardinghandler; + + @Before + public void setUp() { + onBoardingReq = mock(OnBoradingRequest.class); + onboardinghandler = new OnBoardingHandler(); + } + @Test + public void testhandleOnBoardingReq() { + onboardinghandler.handleOnBoardingReq(null); + onboardinghandler.handleOnBoardingReq(onBoardingReq); + when(onBoardingReq.getPackageName()).thenReturn("abc"); + when(onBoardingReq.getPackagePath()).thenReturn("com.java.snippets.core"); + onboardinghandler.handleOnBoardingReq(onBoardingReq); + when(onBoardingReq.getCsarId()).thenReturn("com.java.snippets.core"); + /*onboardinghandler.handleOnBoardingReq(onBoardingReq); + LifecycleTestHook lifecycleTestHook = mock(LifecycleTestHook.class); + when(lifecycleTestHook.exec(onBoardingReq)).thenReturn(200); + assertEquals(lifecycleTestHook.exec(onBoardingReq),200);*/ + } + +}
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestResponseTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestResponseTest.java new file mode 100644 index 00000000..2e74b8f4 --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestResponseTest.java @@ -0,0 +1,41 @@ +/** + * Copyright 2017 Huawei Technologies Co., Ltd. + * + * 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. + */ + +package org.onap.vnfsdk.marketplace.rest; + +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.*; + +public class RestResponseTest { + + private RestResponse restResponse; + + @Before + public void setUp() { + restResponse = new RestResponse(); + } + + @Test + public void testSetterGetter() { + restResponse.setResult("huawei"); + assertEquals(restResponse.getResult(), "huawei"); + restResponse.setStatusCode(200); + assertThat(restResponse.getStatusCode(),is(200)); + } +}
\ No newline at end of file diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestfulClientTest.java b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestfulClientTest.java new file mode 100644 index 00000000..177baa93 --- /dev/null +++ b/vnfmarket-be/vnf-sdk-marketplace/src/test/java/org/onap/vnfsdk/marketplace/rest/RestfulClientTest.java @@ -0,0 +1,82 @@ +/** + * Copyright 2017 Huawei Technologies Co., Ltd. + * <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. + */ + +package org.onap.vnfsdk.marketplace.rest; + +import org.apache.http.HttpEntity; +import org.apache.http.HttpHost; +import org.apache.http.HttpRequest; +import org.apache.http.HttpResponse; +import org.apache.http.impl.client.CloseableHttpClient; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.onap.vnfsdk.marketplace.rest.RestfulClient.HttpMethod.PUT; +import static org.powermock.api.mockito.PowerMockito.when; + +public class RestfulClientTest { + + + private RestfulClient restfulClient; + private HttpEntity entity; + + @Before + public void setUp() { + restfulClient = new RestfulClient(); + entity = mock(HttpEntity.class); + } + + + @Test + public void testGet() { + RestfulClient.get("172.11.10.22,1212", 1211, "http://localhost"); + } + + @Test + public void testPost() { + RestfulClient.post("172.11.10.22,1212", 1211, "http://localhost", null); + } + + @Test + public void testDelete() { + RestfulClient.delete("172.11.10.22,1212", 1211, "http://localhost"); + } + + @Test + public void testSendPostRequest() { + RestfulClient.sendPostRequest("172.11.10.22,1212", "1211", "http://www.engineering.uiowa.edu/~hawkeng//fall01/graphics/potato.gif", "jason"); + HttpResponse httpResponse = mock(HttpResponse.class); + HttpEntity httpEntity = mock(HttpEntity.class); + when(httpResponse.getEntity()).thenReturn(httpEntity); + assertEquals(httpResponse.getEntity(), httpEntity); + + } + + @Test + public void testExecuteHttp() throws Exception{ + RestfulClient.executeHttp(PUT, "172.11.10.22,1212", 1211, "http://localhost", null); + /*HttpResponse httpResponse = mock(HttpResponse.class); + CloseableHttpClient httpclient= mock(CloseableHttpClient.class); + HttpEntity httpEntity= mock(HttpEntity.class); + when(httpResponse.getEntity()).thenReturn(null); + assertEquals(httpResponse.getEntity(), null);*/ + + + } + +}
\ No newline at end of file |