diff options
author | Ittay Stern <ittay.stern@att.com> | 2019-03-11 09:34:34 +0200 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-03-17 17:02:43 +0200 |
commit | 66af8b9b391879be78660d6ccb0a1f1f9340b423 (patch) | |
tree | fc0d510f7ea28a437bcb1e3b950d1281ac88a4e4 /vid-automation/src/test/java/org/onap/vid/api/BaseMsoApiTest.java | |
parent | 37ad0cc1d36ec6ff68ec39fcaaf2617eef7d08fe (diff) |
Merge automation from ECOMP's repository
Reference commit in ECOMP: 8e92a8c6
Issue-ID: VID-378
Change-Id: Ia32f4813378ef95097f788246aa5b1172e20ca48
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-automation/src/test/java/org/onap/vid/api/BaseMsoApiTest.java')
-rw-r--r-- | vid-automation/src/test/java/org/onap/vid/api/BaseMsoApiTest.java | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/vid-automation/src/test/java/org/onap/vid/api/BaseMsoApiTest.java b/vid-automation/src/test/java/org/onap/vid/api/BaseMsoApiTest.java deleted file mode 100644 index 1495f1852..000000000 --- a/vid-automation/src/test/java/org/onap/vid/api/BaseMsoApiTest.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.onap.vid.api; - -import com.google.common.collect.ImmutableMap; -import org.json.JSONException; -import org.onap.vid.model.mso.MsoResponseWrapper2; -import org.skyscreamer.jsonassert.JSONAssert; -import org.skyscreamer.jsonassert.JSONCompareMode; -import org.springframework.http.HttpMethod; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.HttpServerErrorException; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; -import vid.automation.test.services.SimulatorApi; -import vid.automation.test.services.SimulatorApi.RegistrationStrategy; - -import java.io.IOException; -import java.lang.reflect.Method; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - -public class BaseMsoApiTest extends BaseApiTest { - - @BeforeClass - public void login() { - super.login(); - } - - protected void callMsoWithSimulatedErrorResponse(String expectationJsonFileName, ImmutableMap<String, Object> replacementsForJson, String targetUri, String basicRequestBody, int expectedErrorCode, String expectedResult, HttpMethod method) throws IOException { - SimulatorApi.registerExpectation(expectationJsonFileName, replacementsForJson, RegistrationStrategy.CLEAR_THEN_SET); - try { - MsoResponseWrapper2 responseWrapper = callMsoForResponseWrapper(method, targetUri, basicRequestBody); - - assertThat("Wrong propagated status from MSO", responseWrapper.getStatus(), is(expectedErrorCode)); - assertThat("Wrong propagated body from MSO", getCleanJsonString(responseWrapper.getEntity()), is(expectedResult)); - }catch(HttpClientErrorException | HttpServerErrorException e) { - assertThat("Wrong propagated status from MSO", e.getStatusCode().value(), is(expectedErrorCode)); - } - } - - - protected void callMsoWithFineRequest(String expectationJsonFileName, ImmutableMap<String, Object> replacementsForJson, String targetUri, String requestBody, int expectedStatusCode, String expectedResult, HttpMethod method) throws IOException { - SimulatorApi.registerExpectation(expectationJsonFileName, replacementsForJson, RegistrationStrategy.CLEAR_THEN_SET); - - MsoResponseWrapper2 responseWrapper = callMsoForResponseWrapper(method, targetUri, requestBody); - - assertThat("Wrong propagated status from MSO", responseWrapper.getStatus(), is(expectedStatusCode)); - try { - JSONAssert.assertEquals("Wrong propagated body from MSO", expectedResult, getCleanJsonString(responseWrapper.getEntity()), JSONCompareMode.NON_EXTENSIBLE); - } catch (JSONException e) { - throw new RuntimeException(e); - } - } - - protected MsoResponseWrapper2 callMsoForResponseWrapper(HttpMethod method, String uri, String body) { - MsoResponseWrapper2 responseWrapper; - switch (method) { - case POST: - responseWrapper = restTemplate.postForObject(uri, body, MsoResponseWrapper2.class); - break; - case GET: - default: - responseWrapper = restTemplate.getForObject(uri, MsoResponseWrapper2.class); - break; - } - - System.out.println("response: " + responseWrapper); - - return responseWrapper; - } - - @DataProvider - public static Object[][] errorCodes(Method test) { - return new Object[][]{ - {500},{505}, {400}, {401}, {404}, {405} - }; - } -} |