aboutsummaryrefslogtreecommitdiffstats
path: root/cloudify-client/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'cloudify-client/src/test')
-rw-r--r--cloudify-client/src/test/java/org/onap/so/cloudify/BeanMultiTest.java60
-rw-r--r--cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTest.java107
-rw-r--r--cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProviderTest.java56
-rw-r--r--cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientConnectorTest.java255
-rw-r--r--cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java144
-rw-r--r--cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/BlueprintsResourceTest.java144
-rw-r--r--cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/DeploymentsResourceTest.java145
-rw-r--r--cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/ExecutionsResourceTest.java174
-rw-r--r--cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/NodeInstancesResourceTest.java96
9 files changed, 0 insertions, 1181 deletions
diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/BeanMultiTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/BeanMultiTest.java
deleted file mode 100644
index 4028b71109..0000000000
--- a/cloudify-client/src/test/java/org/onap/so/cloudify/BeanMultiTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.so.cloudify;
-
-import org.junit.Before;
-import org.junit.Test;
-import com.openpojo.reflection.PojoClass;
-import com.openpojo.reflection.PojoClassFilter;
-import com.openpojo.reflection.filters.FilterEnum;
-import com.openpojo.reflection.impl.PojoClassFactory;
-import com.openpojo.validation.Validator;
-import com.openpojo.validation.ValidatorBuilder;
-import com.openpojo.validation.rule.impl.GetterMustExistRule;
-import com.openpojo.validation.rule.impl.SetterMustExistRule;
-import com.openpojo.validation.test.impl.GetterTester;
-import com.openpojo.validation.test.impl.SetterTester;
-
-public class BeanMultiTest {
-
- Validator validator;
- PojoClassFilter enumFilter;
- private PojoClassFilter filterTestClasses = new FilterTestClasses();
-
- @Before
- public void setup() {
- enumFilter = new FilterEnum();
- validator = ValidatorBuilder.create().with(new SetterMustExistRule(), new GetterMustExistRule())
- .with(new SetterTester(), new GetterTester()).build();
- }
-
- @Test
- public void validateBeansMsoApihandlerBeans() {
-
- validator.validate("org.onap.so.cloudify.v3.model", enumFilter);
- }
-
- private static class FilterTestClasses implements PojoClassFilter {
- public boolean include(PojoClass pojoClass) {
- return !pojoClass.getSourcePath().contains("/src/test/java");
- }
- }
-}
diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTest.java
deleted file mode 100644
index 88974acb11..0000000000
--- a/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. 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.so.cloudify.base.client;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import static org.junit.Assert.assertEquals;
-import org.apache.http.HttpStatus;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.so.cloudify.v3.model.Execution;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
-public class CloudifyClientTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void clientCreate() {
- wireMockRule.stubFor(
- get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody("{\"id\": \"123\"}").withStatus(HttpStatus.SC_OK)));
- int port = wireMockRule.port();
- CloudifyClient cc = new CloudifyClient("http://localhost:" + port);
- cc.setToken("token");
- CloudifyRequest<Execution> crx = cc.get("/testUrl", Execution.class);
- Execution x = crx.execute();
- assertEquals("123", x.getId());
- }
-
- @Test
- public void clientCreateWithBadConnector() {
- thrown.expect(CloudifyResponseException.class);
- wireMockRule.stubFor(
- get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody("{\"id\": \"123\"}").withStatus(HttpStatus.SC_OK)));
- int port = wireMockRule.port();
- CloudifyClientConnector ccc = new CloudifyClientConnector() {
- @Override
- public <T> CloudifyResponse request(CloudifyRequest<T> request) {
- throw new CloudifyResponseException("test case", 401);
- }
- };
- CloudifyClient cc = new CloudifyClient("http://localhost:" + port, ccc);
- // cc.setToken("token");
- CloudifyRequest<Execution> crx = cc.get("/testUrl", Execution.class);
- Execution x = crx.execute();
- }
-
- @Test
- public void clientCreateWithBadConnectorAndToken() {
- thrown.expect(CloudifyResponseException.class);
- wireMockRule.stubFor(
- get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody("{\"id\": \"123\"}").withStatus(HttpStatus.SC_OK)));
- int port = wireMockRule.port();
- CloudifyClientConnector ccc = new CloudifyClientConnector() {
- @Override
- public <T> CloudifyResponse request(CloudifyRequest<T> request) {
- throw new CloudifyResponseException("test case", 401);
- }
- };
- CloudifyClient cc = new CloudifyClient("http://localhost:" + port, ccc);
- cc.setToken("token");
- CloudifyRequest<Execution> crx = cc.get("/testUrl", Execution.class);
- Execution x = crx.execute();
- }
-
- @Test
- public void clientCreateWithTenant() {
- wireMockRule.stubFor(
- get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody("{\"id\": \"123\"}").withStatus(HttpStatus.SC_OK)));
- int port = wireMockRule.port();
- CloudifyClient cc = new CloudifyClient("http://localhost:" + port, "other_tenant");
- cc.setToken("token");
- cc.property("property", "value");
- CloudifyRequest<Execution> crx = cc.get("/testUrl", Execution.class);
- Execution x = crx.execute();
- assertEquals("123", x.getId());
- }
-
-}
diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProviderTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProviderTest.java
deleted file mode 100644
index 77152a2dd0..0000000000
--- a/cloudify-client/src/test/java/org/onap/so/cloudify/base/client/CloudifyClientTokenProviderTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. 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.so.cloudify.base.client;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import static org.junit.Assert.assertEquals;
-import org.apache.http.HttpStatus;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
-public class CloudifyClientTokenProviderTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void createTokenProvider() {
- wireMockRule.stubFor(get(urlPathEqualTo("/testUrl/api/v3/tokens"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody("{\"role\": \"user\", \"value\": \"tokenVal\"}").withStatus(HttpStatus.SC_OK)));
- int port = wireMockRule.port();
-
- CloudifyClientTokenProvider cctp =
- new CloudifyClientTokenProvider("http://localhost:" + port + "/testUrl", "user", "pswd");
- String token = cctp.getToken();
- assertEquals("tokenVal", token);
- token = cctp.getToken();
- assertEquals("tokenVal", token);
- cctp.expireToken();
- }
-}
diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientConnectorTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientConnectorTest.java
deleted file mode 100644
index c85b88f7f3..0000000000
--- a/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientConnectorTest.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.so.cloudify.connector.http;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import com.github.tomakehurst.wiremock.http.Fault;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.verify;
-import static com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.putRequestedFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.deleteRequestedFor;
-import org.apache.http.HttpStatus;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertEquals;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import org.onap.so.cloudify.base.client.CloudifyConnectException;
-import org.onap.so.cloudify.base.client.CloudifyRequest;
-import org.onap.so.cloudify.base.client.CloudifyResponseException;
-import org.onap.so.cloudify.base.client.Entity;
-import org.onap.so.cloudify.base.client.HttpMethod;
-import org.onap.so.cloudify.v3.model.Deployment;
-
-public class HttpClientConnectorTest {
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void sunnyDay_POST() {
- wireMockRule.stubFor(post(urlPathEqualTo("/testUrl")).willReturn(aResponse()
- .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK)));
- int port = wireMockRule.port();
- HttpClientConnector conector = new HttpClientConnector();
- CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>();
- Deployment deployment = new Deployment();
- deployment.setId("id");
- request.entity(deployment, "application/json");
- request.endpoint("http://localhost:" + port + "/testUrl");
- request.setBasicAuthentication("USER", "PASSWORD");
- request.header("Content-Type", "application/json");
- request.method(HttpMethod.POST);
- conector.request(request);
- verify(postRequestedFor(urlEqualTo("/testUrl")));
- }
-
-
- @Test
- public void sunnyDay_GET() {
- wireMockRule.stubFor(get(urlPathEqualTo("/testUrl")).willReturn(aResponse()
- .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK)));
- int port = wireMockRule.port();
- HttpClientConnector conector = new HttpClientConnector();
- CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>();
- request.endpoint("http://localhost:" + port + "/testUrl");
- request.setBasicAuthentication("USER", "PASSWORD");
- request.method(HttpMethod.GET);
- conector.request(request);
- verify(getRequestedFor(urlEqualTo("/testUrl")));
- }
-
- @Test
- public void sunnyDay_PUT() {
- wireMockRule.stubFor(put(urlPathEqualTo("/testUrl")).willReturn(aResponse()
- .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK)));
- int port = wireMockRule.port();
- HttpClientConnector conector = new HttpClientConnector();
- CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>();
- request.endpoint("http://localhost:" + port + "/testUrl");
- request.setBasicAuthentication("USER", "PASSWORD");
- request.method(HttpMethod.PUT);
- conector.request(request);
- verify(putRequestedFor(urlEqualTo("/testUrl")));
- }
-
-
- @Test
- public void sunnyDay_DELETE() {
- wireMockRule.stubFor(delete(urlPathEqualTo("/testUrl")).willReturn(aResponse()
- .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK)));
- int port = wireMockRule.port();
- HttpClientConnector conector = new HttpClientConnector();
- CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>();
- request.endpoint("http://localhost:" + port + "/testUrl");
- request.setBasicAuthentication("USER", "PASSWORD");
- request.method(HttpMethod.DELETE);
- conector.request(request);
- verify(deleteRequestedFor(urlEqualTo("/testUrl")));
- }
-
-
- @Test
- public void rainyDay_PATCH() {
- thrown.expect(HttpClientException.class);
- thrown.expectMessage("Unrecognized HTTP Method: PATCH");
- HttpClientConnector conector = new HttpClientConnector();
- CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>();
- request.endpoint("http://localhost:123123/testUrl");
- request.setBasicAuthentication("USER", "PASSWORD");
- request.method(HttpMethod.PATCH);
- conector.request(request);
-
- }
-
- @Test
- public void rainyDayRunTimeException() {
- wireMockRule.stubFor(post(urlEqualTo("/503"))
- .willReturn(aResponse().withStatus(503).withHeader("Content-Type", "text/plain").withBody("failure")));
- thrown.expect(RuntimeException.class);
- thrown.expectMessage("Unexpected client exception");
- HttpClientConnector conector = new HttpClientConnector();
- CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>();
- request.endpoint("http://localhost:123123/503");
- request.setBasicAuthentication("USER", "PASSWORD");
- request.method(HttpMethod.POST);
- conector.request(request);
-
- }
-
- @Test
- public void rainyDayBadUri() {
- wireMockRule.stubFor(post(urlPathEqualTo("/testUrl")).willReturn(aResponse()
- .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK)));
- thrown.expect(HttpClientException.class);
- int port = wireMockRule.port();
- HttpClientConnector conector = new HttpClientConnector();
- CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>();
- Deployment deployment = new Deployment();
- deployment.setId("id");
- request.entity(deployment, "application/json");
- request.endpoint("(@#$@(#*$&asfasdf");
- request.setBasicAuthentication("USER", "PASSWORD");
- request.header("Content-Type", "application/json");
- request.method(HttpMethod.POST);
- conector.request(request);
- }
-
- @Test
- public void sunnyDayWithJsonEntity_POST() {
- wireMockRule.stubFor(post(urlPathEqualTo("/testUrl")).willReturn(aResponse()
- .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK)));
- int port = wireMockRule.port();
- HttpClientConnector conector = new HttpClientConnector();
-
- Deployment deployment = new Deployment();
- deployment.setId("id");
-
- CloudifyRequest<Deployment> request =
- new CloudifyRequest<Deployment>(null, HttpMethod.POST, "/", Entity.json(deployment), null);
-
- request.endpoint("http://localhost:" + port);
- request.path("testUrl");
- request.header("Content-Type", "application/json");
- request.header("Content-Type", null);
-
- request.returnType(Deployment.class);
- assertEquals(Deployment.class, request.returnType());
-
- Entity<Deployment> t = request.json(deployment);
- assertEquals(t.getEntity().getId(), "id");
-
- request.queryParam("test", "one").queryParam("test", "two");
-
- conector.request(request);
-
- verify(postRequestedFor(urlEqualTo("/testUrl?test=two")));
- }
-
- @Test
- public void sunnyDayWithStreamEntity_POST() {
- wireMockRule.stubFor(post(urlPathEqualTo("/testUrl")).willReturn(aResponse()
- .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_OK)));
- int port = wireMockRule.port();
- HttpClientConnector conector = new HttpClientConnector();
-
- InputStream is = new ByteArrayInputStream("{}".getBytes(StandardCharsets.UTF_8));
-
- CloudifyRequest<Deployment> request =
- new CloudifyRequest<Deployment>(null, HttpMethod.POST, "/testUrl", Entity.stream(is), null);
-
- request.endpoint("http://localhost:" + port);
- request.setBasicAuthentication("USER", "PASSWORD");
- request.header("Content-Type", "application/json");
-
- conector.request(request);
- verify(postRequestedFor(urlEqualTo("/testUrl")));
- }
-
- @Test
- public void rainyDayGarbageData() {
- wireMockRule.stubFor(
- get(urlPathEqualTo("/testUrl")).willReturn(aResponse().withFault(Fault.RANDOM_DATA_THEN_CLOSE)));
- thrown.expect(CloudifyConnectException.class);
- int port = wireMockRule.port();
- HttpClientConnector conector = new HttpClientConnector();
- CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>();
- request.endpoint("http://localhost:" + port + "/testUrl");
- request.setBasicAuthentication("USER", "PASSWORD");
- request.method(HttpMethod.GET);
- conector.request(request);
- }
-
- @Test
- public void rainyDayEmptyResponse() {
- wireMockRule.stubFor(get(urlPathEqualTo("/testUrl")).willReturn(aResponse()
- .withHeader("Content-Type", "application/json").withBody("TEST").withStatus(HttpStatus.SC_NOT_FOUND)));
-
- thrown.expect(HttpClientException.class);
- int port = wireMockRule.port();
- HttpClientConnector conector = new HttpClientConnector();
- CloudifyRequest<Deployment> request = new CloudifyRequest<Deployment>();
- request.endpoint("http://localhost:" + port + "/testUrl");
- request.setBasicAuthentication("USER", "PASSWORD");
- request.method(HttpMethod.GET);
- conector.request(request); // gets down to "Get here on an error response (4XX-5XX)", then tries to throw a
- // CloudifyResponseException, which calls getEntity, which tries to parse an HTML
- // error page as a JSON, which causes the HttpClientException.
- }
-
-
-}
diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java
deleted file mode 100644
index 6010726669..0000000000
--- a/cloudify-client/src/test/java/org/onap/so/cloudify/connector/http/HttpClientRedirectStrategyTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * ============LICENSE_START======================================================= ONAP : SO
- * ================================================================================ Copyright (C) 2018 Nokia.
- * ============================================================================= 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.so.cloudify.connector.http;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
-import static org.mockito.Mockito.mock;
-import java.net.URI;
-import java.net.URISyntaxException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.ProtocolException;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.client.methods.HttpOptions;
-import org.apache.http.client.methods.HttpPatch;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.methods.HttpTrace;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.protocol.HttpContext;
-import org.junit.Test;
-
-public class HttpClientRedirectStrategyTest {
-
- private HttpClientRedirectStrategy httpClientRedirectStrategy = new HttpClientRedirectStrategy();
-
- @Test
- public void isRedirectable_shouldReturnFalse_forNonRedirectableHttpMethods() {
- assertThat(httpClientRedirectStrategy.isRedirectable(HttpPost.METHOD_NAME)).isFalse();
- assertThat(httpClientRedirectStrategy.isRedirectable(HttpPatch.METHOD_NAME)).isFalse();
- assertThat(httpClientRedirectStrategy.isRedirectable(HttpPut.METHOD_NAME)).isFalse();
- assertThat(httpClientRedirectStrategy.isRedirectable(HttpOptions.METHOD_NAME)).isFalse();
- assertThat(httpClientRedirectStrategy.isRedirectable(HttpTrace.METHOD_NAME)).isFalse();
- }
-
- @Test
- public void isRedirectable_shouldReturnTrue_forRedirectableHttpMethods() {
- assertThat(httpClientRedirectStrategy.isRedirectable(HttpGet.METHOD_NAME)).isTrue();
- assertThat(httpClientRedirectStrategy.isRedirectable(HttpDelete.METHOD_NAME)).isTrue();
- assertThat(httpClientRedirectStrategy.isRedirectable(HttpHead.METHOD_NAME)).isTrue();
- }
-
- @Test
- public void getRedirect_shouldReturnHttpHeadUriRequest() throws URISyntaxException, ProtocolException {
- assertHttpUriRequestFor(HttpHead.METHOD_NAME, HttpHead.class);
- }
-
- @Test
- public void getRedirect_shouldReturnHttpGetUriRequest() throws URISyntaxException, ProtocolException {
- assertHttpUriRequestFor(HttpGet.METHOD_NAME, HttpGet.class);
- }
-
- private void assertHttpUriRequestFor(String methodName, Class<? extends HttpUriRequest> expectedHttpMethodClass)
- throws URISyntaxException, ProtocolException {
- // GIVEN
- HttpRequest request = mock(HttpRequest.class, RETURNS_DEEP_STUBS);
- given(request.getRequestLine().getMethod()).willReturn(methodName);
- HttpResponse response = null;
- HttpContext context = null;
- URI expectedUri = new URI("http://localhost/host");
- // WHEN
- HttpUriRequest httpUriRequest =
- new TestableHttpClientRedirectStrategy(expectedUri).getRedirect(request, response, context);
- // THEN
- assertThat(httpUriRequest).isInstanceOf(expectedHttpMethodClass);
- assertThat(httpUriRequest.getURI()).isEqualTo(expectedUri);
- }
-
- @Test
- public void getRedirect_shouldReturnHttpGetUri_byDefault() throws URISyntaxException, ProtocolException {
- // GIVEN
- HttpRequest request = mock(HttpRequest.class, RETURNS_DEEP_STUBS);
- given(request.getRequestLine().getMethod()).willReturn(HttpPost.METHOD_NAME);
- HttpResponse response = mock(HttpResponse.class, RETURNS_DEEP_STUBS);
- given(response.getStatusLine().getStatusCode()).willReturn(HttpStatus.SC_ACCEPTED);
- URI expectedUri = new URI("http://localhost/host");
- HttpContext context = null;
- // WHEN
- HttpUriRequest httpUriRequest =
- new TestableHttpClientRedirectStrategy(expectedUri).getRedirect(request, response, context);
- // THEN
- assertThat(httpUriRequest).isInstanceOf(HttpGet.class);
- assertThat(httpUriRequest.getURI()).isEqualTo(expectedUri);
- }
-
- @Test
- public void getRedirect_shouldCopyHttpRequestAndSetNewUri_forMovedTemporarilyStatus()
- throws URISyntaxException, ProtocolException {
- assertHttpRequestIsCopied(HttpStatus.SC_MOVED_TEMPORARILY);
- }
-
- @Test
- public void getRedirect_shouldCopyHttpRequestAndSetNewUri_forTemporaryRedirectStatus()
- throws URISyntaxException, ProtocolException {
- assertHttpRequestIsCopied(HttpStatus.SC_TEMPORARY_REDIRECT);
- }
-
- private void assertHttpRequestIsCopied(int expectedHttpStatus) throws URISyntaxException, ProtocolException {
- // GIVEN
- HttpRequest request = mock(HttpRequest.class, RETURNS_DEEP_STUBS);
- given(request.getRequestLine().getMethod()).willReturn(HttpGet.METHOD_NAME);
- given(request.getRequestLine().getUri()).willReturn("http://hostname");
- HttpResponse response = mock(HttpResponse.class, RETURNS_DEEP_STUBS);
- given(response.getStatusLine().getStatusCode()).willReturn(expectedHttpStatus);
- URI expectedUri = new URI("http://localhost/host");
- HttpContext context = null;
- // WHEN
- HttpUriRequest httpUriRequest =
- new TestableHttpClientRedirectStrategy(expectedUri).getRedirect(request, response, context);
- // THEN
- assertThat(httpUriRequest).isInstanceOf(HttpGet.class);
- assertThat(httpUriRequest.getURI()).isEqualTo(expectedUri);
- }
-
- private static class TestableHttpClientRedirectStrategy extends HttpClientRedirectStrategy {
-
- private final URI expectedUri;
-
- public TestableHttpClientRedirectStrategy(URI expectedUri) {
- this.expectedUri = expectedUri;
- }
-
- @Override
- public URI getLocationURI(HttpRequest request, HttpResponse response, HttpContext context) {
- return expectedUri;
- }
- }
-}
diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/BlueprintsResourceTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/BlueprintsResourceTest.java
deleted file mode 100644
index cba3bf8fdc..0000000000
--- a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/BlueprintsResourceTest.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. 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.so.cloudify.v3.client;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import static org.junit.Assert.assertEquals;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import org.apache.http.HttpStatus;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.so.cloudify.v3.client.BlueprintsResource.DeleteBlueprint;
-import org.onap.so.cloudify.v3.client.BlueprintsResource.GetBlueprint;
-import org.onap.so.cloudify.v3.client.BlueprintsResource.ListBlueprints;
-import org.onap.so.cloudify.v3.client.BlueprintsResource.UploadBlueprint;
-import org.onap.so.cloudify.v3.model.Blueprint;
-import org.onap.so.cloudify.v3.model.Blueprints;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
-public class BlueprintsResourceTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void cloudifyClientBlueprintFromStream() {
- wireMockRule.stubFor(put(urlPathEqualTo("/api/v3/blueprints/123"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- BlueprintsResource br = c.blueprints();
- InputStream is = new ByteArrayInputStream("{}".getBytes(StandardCharsets.UTF_8));
- UploadBlueprint ub = br.uploadFromStream("123", "blueprint.json", is);
- Blueprint b = ub.execute();
- assertEquals("123", b.getId());
- }
-
- @Test
- public void cloudifyClientBlueprintFromUrl() {
- wireMockRule.stubFor(put(urlPathEqualTo("/api/v3/blueprints/123"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- BlueprintsResource br = c.blueprints();
- UploadBlueprint ub = br.uploadFromUrl("123", "blueprint.json", "http://localhost:" + port + "/blueprint");
- Blueprint b = ub.execute();
- assertEquals("123", b.getId());
- }
-
- @Test
- public void cloudifyClientBlueprintDelete() {
- wireMockRule.stubFor(delete(urlPathEqualTo("/api/v3/blueprints/123"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- BlueprintsResource br = c.blueprints();
- DeleteBlueprint db = br.deleteById("123");
- Blueprint b = db.execute();
- assertEquals("123", b.getId());
- }
-
- @Test
- public void cloudifyClientBlueprintList() {
- wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/blueprints"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody("{\"items\": [{\"id\": \"123\"}]}").withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- BlueprintsResource br = c.blueprints();
- ListBlueprints lb = br.list();
- Blueprints b = lb.execute();
- assertEquals("123", b.getItems().get(0).getId());
- }
-
- @Test
- public void cloudifyClientBlueprintGetById() {
- wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/blueprints/123"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- BlueprintsResource br = c.blueprints();
- GetBlueprint gb = br.getById("123");
- Blueprint b = gb.execute();
- assertEquals("123", b.getId());
- }
-
- @Test
- public void cloudifyClientBlueprintGetMetadataById() {
- wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/blueprints/123"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{\"id\": \"123\"}")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- BlueprintsResource br = c.blueprints();
- GetBlueprint gb = br.getMetadataById("123");
- Blueprint b = gb.execute();
- assertEquals("123", b.getId());
- }
-
-
-}
diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/DeploymentsResourceTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/DeploymentsResourceTest.java
deleted file mode 100644
index 2acd4ba5a3..0000000000
--- a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/DeploymentsResourceTest.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. 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.so.cloudify.v3.client;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.http.HttpStatus;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.so.cloudify.v3.client.DeploymentsResource.CreateDeployment;
-import org.onap.so.cloudify.v3.client.DeploymentsResource.DeleteDeployment;
-import org.onap.so.cloudify.v3.client.DeploymentsResource.GetDeployment;
-import org.onap.so.cloudify.v3.client.DeploymentsResource.GetDeploymentOutputs;
-import org.onap.so.cloudify.v3.client.DeploymentsResource.ListDeployments;
-import org.onap.so.cloudify.v3.model.CreateDeploymentParams;
-import org.onap.so.cloudify.v3.model.Deployment;
-import org.onap.so.cloudify.v3.model.Deployments;
-import org.onap.so.cloudify.v3.model.DeploymentOutputs;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
-public class DeploymentsResourceTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void cloudifyDeploymentsCreate() {
- wireMockRule.stubFor(put(urlPathEqualTo("/api/v3/deployments/123"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- DeploymentsResource br = c.deployments();
-
- CreateDeploymentParams cdp = new CreateDeploymentParams();
- cdp.setBlueprintId("123");
- Map<String, Object> inputs = new HashMap<String, Object>();
- cdp.setInputs(inputs);
- CreateDeployment cd = br.create("123", cdp);
- Deployment d = cd.execute();
- assertEquals("123", d.getId());
- }
-
- @Test
- public void cloudifyDeploymentsList() {
- wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/deployments"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody("{ \"items\": {\"id\": \"123\" } } ").withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- DeploymentsResource br = c.deployments();
- ListDeployments ld = br.list();
- Deployments d = ld.execute();
- assertEquals("123", d.getItems().get(0).getId());
- }
-
- @Test
- public void cloudifyDeploymentsGet() {
- wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/deployments/123"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- DeploymentsResource br = c.deployments();
- GetDeployment gd = br.byId("123");
- Deployment d = gd.execute();
- assertEquals("123", d.getId());
- }
-
- @Test
- public void cloudifyDeploymentsGetOutputs() {
- wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/deployments/123/outputs"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody("{ \"deployment_id\": \"123\" }").withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- DeploymentsResource br = c.deployments();
- GetDeploymentOutputs gdo = br.outputsById("123");
- DeploymentOutputs d = gdo.execute();
- assertEquals("123", d.getDeploymentId());
-
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("test", "answer");
- assertEquals("answer", d.getMapValue(map, "test", String.class));
-
- Integer i = d.getMapValue(map, "nil", Integer.class);
- assertNull(i);
-
- i = d.getMapValue(map, "test", Integer.class);
- assertNull(i);
- }
-
- @Test
- public void cloudifyDeploymentsDelete() {
- wireMockRule.stubFor(delete(urlPathEqualTo("/api/v3/deployments/name"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- DeploymentsResource br = c.deployments();
- DeleteDeployment cd = br.deleteByName("name");
- Deployment d = cd.execute();
- assertEquals("123", d.getId());
- }
-
-}
diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/ExecutionsResourceTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/ExecutionsResourceTest.java
deleted file mode 100644
index 7b63c6eecb..0000000000
--- a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/ExecutionsResourceTest.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. 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.so.cloudify.v3.client;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.patch;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import static org.junit.Assert.assertEquals;
-import org.apache.http.HttpStatus;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.so.cloudify.connector.http.HttpClientException;
-import org.onap.so.cloudify.v3.client.ExecutionsResource.CancelExecution;
-import org.onap.so.cloudify.v3.client.ExecutionsResource.GetExecution;
-import org.onap.so.cloudify.v3.client.ExecutionsResource.ListExecutions;
-import org.onap.so.cloudify.v3.client.ExecutionsResource.StartExecution;
-import org.onap.so.cloudify.v3.client.ExecutionsResource.UpdateExecution;
-import org.onap.so.cloudify.v3.model.CancelExecutionParams;
-import org.onap.so.cloudify.v3.model.Execution;
-import org.onap.so.cloudify.v3.model.Executions;
-import org.onap.so.cloudify.v3.model.StartExecutionParams;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
-public class ExecutionsResourceTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void cloudifyClientExecutions() {
- wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/executions")).willReturn(aResponse()
- .withHeader("Content-Type", "application/json")
- .withBody(
- "{\"items\": [{ \"id\": \"345\" }, { \"id\": \"123\" }], \"metadata\": {\"pagination\": {\"total\": 100, \"offset\": 0, \"size\": 25}}}")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- ExecutionsResource xr = c.executions();
- ListExecutions lx = xr.list();
- Executions x = lx.execute();
- assertEquals("123", x.getItems().get(1).getId());
- }
-
- @Test
- public void cloudifyClientExecutionsSorted() {
- wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/executions")).willReturn(aResponse()
- .withHeader("Content-Type", "application/json")
- .withBody(
- "{\"items\": [{ \"id\": \"123\" }, { \"id\": \"345\" }], \"metadata\": {\"pagination\": {\"total\": 100, \"offset\": 0, \"size\": 25}}}")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- ExecutionsResource xr = c.executions();
- ListExecutions lx = xr.listSorted("id");
- Executions x = lx.execute();
- assertEquals("345", x.getItems().get(1).getId());
- }
-
- @Test
- public void cloudifyClientExecutionsFilter() {
- wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/executions")).willReturn(aResponse()
- .withHeader("Content-Type", "application/json")
- .withBody(
- "{\"items\": [{ \"id\": \"121\" }, { \"id\": \"123\" }], \"metadata\": {\"pagination\": {\"total\": 100, \"offset\": 0, \"size\": 25}}}")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- ExecutionsResource xr = c.executions();
- ListExecutions lx = xr.listFiltered("a=b", "id");
- Executions x = lx.execute();
- assertEquals("123", x.getItems().get(1).getId());
- }
-
- @Test
- public void cloudifyClientExecutionById() {
- wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/executions/123"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- ExecutionsResource xr = c.executions();
- GetExecution gx = xr.byId("123");
- Execution x = gx.execute();
- assertEquals("123", x.getId());
- }
-
- @Test
- public void cloudifyClientStartExecution() {
- wireMockRule.stubFor(post(urlPathEqualTo("/api/v3/executions"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- ExecutionsResource xr = c.executions();
-
- StartExecutionParams params = new StartExecutionParams();
- StartExecution sx = xr.start(params);
- Execution x = sx.execute();
- assertEquals("123", x.getId());
- }
-
- @Test
- public void cloudifyClientUpdateExecution() {
- thrown.expect(HttpClientException.class);
- thrown.expectMessage("Unrecognized HTTP Method: PATCH");
-
- wireMockRule.stubFor(patch(urlPathEqualTo("/api/v3/executions"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- ExecutionsResource xr = c.executions();
-
- UpdateExecution ux = xr.updateStatus("123", "good");
- Execution x = ux.execute();
- assertEquals("123", x.getId());
- }
-
- @Test
- public void cloudifyClientCancelExecution() {
- wireMockRule.stubFor(post(urlPathEqualTo("/api/v3/executions/123"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody("{ \"id\": \"123\" }")
- .withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- ExecutionsResource xr = c.executions();
-
- CancelExecutionParams params = new CancelExecutionParams();
- CancelExecution cx = xr.cancel("123", params);
- Execution x = cx.execute();
- assertEquals("123", x.getId());
- }
-
-
-
-}
diff --git a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/NodeInstancesResourceTest.java b/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/NodeInstancesResourceTest.java
deleted file mode 100644
index d38d0401c3..0000000000
--- a/cloudify-client/src/test/java/org/onap/so/cloudify/v3/client/NodeInstancesResourceTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. 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.so.cloudify.v3.client;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.patch;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import static org.junit.Assert.assertEquals;
-import org.apache.http.HttpStatus;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.onap.so.cloudify.connector.http.HttpClientException;
-import org.onap.so.cloudify.v3.client.NodeInstancesResource.GetNodeInstance;
-import org.onap.so.cloudify.v3.client.NodeInstancesResource.ListNodeInstances;
-import org.onap.so.cloudify.v3.client.NodeInstancesResource.UpdateNodeInstance;
-import org.onap.so.cloudify.v3.model.NodeInstance;
-import org.onap.so.cloudify.v3.model.NodeInstances;
-import org.onap.so.cloudify.v3.model.UpdateNodeInstanceParams;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
-public class NodeInstancesResourceTest {
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort());
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Test
- public void nodeInstanceGet() {
- wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/node-instances/123"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody("{ \"node_instance\": { \"id\": \"123\" } }").withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- NodeInstancesResource nir = c.nodeInstances();
- GetNodeInstance gni = nir.byId("123");
- NodeInstance ni = gni.execute();
- assertEquals("123", ni.getId());
- }
-
- @Test
- public void nodeInstanceList() {
- wireMockRule.stubFor(get(urlPathEqualTo("/api/v3/node-instances"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- // .withBody(" { \"items\": [ { \"node_instance\": { \"id\": \"123\" } } ] } ")
- .withBody(" { \"items\": [ { \"id\": \"123\" } ] } ").withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- NodeInstancesResource nir = c.nodeInstances();
- ListNodeInstances lni = nir.list();
- NodeInstances ni = lni.execute();
- assertEquals("123", ni.getItems().get(0).getId());
- }
-
- @Test
- public void nodeInstanceUpdate() {
- wireMockRule.stubFor(patch(urlPathEqualTo("/api/v3/node-instances/"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody("{ \"node_instance\": { \"id\": \"123\" } }").withStatus(HttpStatus.SC_OK)));
-
- int port = wireMockRule.port();
-
- Cloudify c = new Cloudify("http://localhost:" + port, "tenant");
- NodeInstancesResource nir = c.nodeInstances();
- UpdateNodeInstanceParams params = new UpdateNodeInstanceParams();
-
- UpdateNodeInstance uni = nir.update("123", params);
- thrown.expect(HttpClientException.class); /// ???????
- NodeInstance ni = uni.execute();
- }
-}