From 34f18a178b4b38632f435e776e15ce2f79d58094 Mon Sep 17 00:00:00 2001 From: golabek Date: Wed, 29 Aug 2018 15:29:56 +0200 Subject: Get subscribers rewritten to new rest client Should be merged after: I561f8a5d95ec35fdddc648b24965dd9dac03c9a4 It contains cherry-picked changes from that review Change-Id: I22a9e9ce709ae4dd3abcf7a9cda6354a4f656b00 Issue-ID: VID-269 Signed-off-by: golabek --- .../vid/services/AsyncInstantiationBaseTest.java | 43 ++++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) (limited to 'vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java') diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java index c3d01283d..7ad49a968 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java @@ -1,8 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2018 Nokia. 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.onap.vid.services; import com.google.common.collect.ImmutableMap; +import io.joshworks.restclient.http.HttpResponse; +import java.io.UnsupportedEncodingException; import jersey.repackaged.com.google.common.collect.ImmutableList; -import org.onap.vid.aai.AaiClientInterface; +import org.apache.http.HttpStatus; +import org.apache.http.HttpVersion; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.DefaultHttpResponseFactory; +import org.apache.http.message.BasicStatusLine; +import org.onap.vid.aai.AaiOverTLSClientInterface; import org.onap.vid.aai.AaiResponse; import org.onap.vid.aai.model.AaiNodeQueryResponse; import org.onap.vid.aai.model.ResourceType; @@ -13,8 +41,6 @@ import org.onap.vid.model.serviceInstantiation.VfModule; import org.onap.vid.model.serviceInstantiation.Vnf; import org.onap.vid.mso.RestObject; import org.onap.vid.mso.rest.AsyncRequestStatus; -import org.onap.vid.services.AsyncInstantiationBusinessLogic; -import org.onap.vid.services.AsyncInstantiationBusinessLogicTest; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.togglz.core.manager.FeatureManager; @@ -48,7 +74,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests protected FeatureManager featureManager; @Inject - protected AaiClientInterface aaiClient; + protected AaiOverTLSClientInterface aaiClient; public ServiceInstantiation generateMockServiceInstantiationPayload(boolean isPause, Map vnfs, int bulkSize, boolean isUserProvidedNaming, String projectName, boolean rollbackOnFailure) { ModelInfo modelInfo = createModelInfo(); @@ -174,12 +200,15 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests return restObject; } - protected void mockAaiClientAnyNameFree() { + protected void mockAaiClientAnyNameFree() throws UnsupportedEncodingException { when(aaiClient.searchNodeTypeByName(any(), any())).thenReturn(aaiNodeQueryResponseNameFree()); } - protected AaiResponse aaiNodeQueryResponseNameFree() { - return new AaiResponse<>(new AaiNodeQueryResponse(null),"", 200); + protected HttpResponse aaiNodeQueryResponseNameFree() throws UnsupportedEncodingException { + org.apache.http.HttpResponse response = new DefaultHttpResponseFactory().newHttpResponse(new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, null), null); + response.setEntity(new StringEntity("")); + + return HttpResponse.fallback(new AaiNodeQueryResponse(null)); } protected AaiResponse aaiNodeQueryBadResponse() { -- cgit 1.2.3-korg