diff options
author | 2018-08-12 14:51:28 +0300 | |
---|---|---|
committer | 2018-08-12 15:02:57 +0300 | |
commit | 4a4dcc5185f8ba5a28c7f9fef509f32c0c2389e6 (patch) | |
tree | 23e55ee7e1ad9b91bcc3ef1dbe1fb7b183f8b2b6 /vid-automation/src/test/java/org/opencomp/vid/api/SampleApiTest.java | |
parent | 661a24fd57de02869a9771761e0fcba7eb77d121 (diff) |
vid-automation selenium tests
Change-Id: I6c1b0a0cf3bbfa4314c81f0cc72507db805ec632
Issue-ID: VID-281
Signed-off-by: Sonsino, Ofir (os0695) <os0695@intl.att.com>
Diffstat (limited to 'vid-automation/src/test/java/org/opencomp/vid/api/SampleApiTest.java')
-rw-r--r-- | vid-automation/src/test/java/org/opencomp/vid/api/SampleApiTest.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/vid-automation/src/test/java/org/opencomp/vid/api/SampleApiTest.java b/vid-automation/src/test/java/org/opencomp/vid/api/SampleApiTest.java new file mode 100644 index 00000000..3d8cd566 --- /dev/null +++ b/vid-automation/src/test/java/org/opencomp/vid/api/SampleApiTest.java @@ -0,0 +1,68 @@ +package org.opencomp.vid.api; + +import com.google.common.collect.ImmutableMap; +import org.json.JSONException; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import vid.automation.test.services.SimulatorApi; + +import java.io.IOException; + +import static java.util.Collections.singletonList; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + +public class SampleApiTest extends BaseApiTest { + + private static final String UUID = "927befca-e32c-4f7d-be8d-b4107e0ac31e"; + private static final String FILE_NAME = "a_file_with_request_setup.json"; + private static final String REQUEST_BODY = "{ \"foo\": \"bar\" }"; + + @BeforeClass + public void login() { + super.login(); + } + + @Test(enabled = false) + public void createWithSimplestBody() throws IOException, JSONException { + final String expectedResult = "" + + "{" + + " \"requestReferences\": {" + + " \"requestId\": \"rq1234d1-5a33-55df-13ab-12abad84e331\","+ + " \"instanceId\": \"" + UUID + "\"" + + " }" + + "}"; + + callWithFineRequest(FILE_NAME, + ImmutableMap.of("UUID", UUID), + buildUri(), REQUEST_BODY, + HttpStatus.ACCEPTED.value(), expectedResult); + } + + private String buildUri() { + return uri + "/foo"; + } + + private void callWithFineRequest(String expectationJsonFileName, ImmutableMap<String, Object> replacementsForJson, String targetUri, String requestBody, int expectedStatusCode, String expectedResult) throws JSONException { + SimulatorApi.registerExpectation(expectationJsonFileName, replacementsForJson, SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); + + MyFooResponseType response = restTemplate.postForObject(targetUri, requestBody, MyFooResponseType.class); + + assertThat("Wrong propagated status from MSO", response.getStatus(), is(expectedStatusCode)); + JSONAssert.assertEquals("Wrong propagated body from MSO", expectedResult, getCleanJsonString(response.getEntity()), JSONCompareMode.NON_EXTENSIBLE); + } + + + private class MyFooResponseType { + public int getStatus() { + return 202; + } + + public String getEntity() { + return "baz"; + } + } +} |