2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.asdc.activity;
22 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
23 import static com.github.tomakehurst.wiremock.client.WireMock.post;
24 import static com.github.tomakehurst.wiremock.client.WireMock.put;
25 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
26 import static org.junit.Assert.assertTrue;
27 import static org.mockito.Mockito.when;
28 import org.junit.Test;
29 import org.mockito.Mock;
30 import org.onap.so.asdc.BaseTest;
31 import org.onap.so.asdc.activity.DeployActivitySpecs;
32 import org.onap.so.asdc.activity.beans.ActivitySpecCreateResponse;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.beans.factory.annotation.Value;
35 import org.springframework.core.env.Environment;
36 import org.springframework.http.HttpHeaders;
37 import com.fasterxml.jackson.databind.ObjectMapper;
38 import javax.ws.rs.core.MediaType;
40 public class DeployActivitySpecsITTest extends BaseTest {
42 protected Environment env;
44 @Value("${wiremock.server.port}")
45 private String wiremockPort;
48 private DeployActivitySpecs deployActivitySpecs;
51 public void deployActivitySpecsIT_Test() throws Exception {
52 ActivitySpecCreateResponse activitySpecCreateResponse = new ActivitySpecCreateResponse();
53 activitySpecCreateResponse.setId("testActivityId");
54 HttpHeaders headers = new HttpHeaders();
55 headers.set("Accept", MediaType.APPLICATION_JSON);
56 headers.set("Content-Type", MediaType.APPLICATION_JSON);
58 ObjectMapper mapper = new ObjectMapper();
59 String body = mapper.writeValueAsString(activitySpecCreateResponse);
61 wireMockServer.stubFor(post(urlPathMatching("/v1.0/activity-spec"))
62 .willReturn(aResponse().withHeader("Content-Type", "application/json")
63 .withStatus(org.springframework.http.HttpStatus.OK.value()).withBody(body)));
65 when(env.getProperty("mso.asdc.config.activity.endpoint")).thenReturn("http://localhost:8090");
67 String urlPath = "/v1.0/activity-spec/testActivityId/versions/latest/actions";
69 wireMockServer.stubFor(
70 put(urlPathMatching(urlPath)).willReturn(aResponse().withHeader("Content-Type", "application/json")
71 .withStatus(org.springframework.http.HttpStatus.OK.value())));
73 deployActivitySpecs.deployActivities();
74 assertTrue(activitySpecCreateResponse.getId().equals("testActivityId"));