import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageOnboardingNotification;
import org.onap.so.svnfm.simulator.config.SvnfmApplication;
+import org.onap.so.svnfm.simulator.controller.SubscriptionNotificationController;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
+import org.springframework.http.converter.json.GsonHttpMessageConverter;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.client.MockRestServiceServer;
public class TestSubscriptionNotificationController {
private static final Logger LOGGER = getLogger(TestSubscriptionNotificationController.class);
+ private static final String SOL003_SUBSCRIPTION_URL = "http://so-etsi-sol003-adapter.onap:9092" + VNFM_ADAPTER_SUBSCRIPTION_ENDPOINT;
@LocalServerPort
private int port;
private RestTemplate restTemplate;
private MockRestServiceServer mockRestServiceServer;
- @Autowired
private TestRestTemplate testRestTemplate;
private Gson gson;
@Before
public void setup() {
mockRestServiceServer = MockRestServiceServer.bindTo(restTemplate).build();
- gson = new GsonBuilder().create();
+ gson = new GsonBuilder().registerTypeAdapter(LocalDateTime.class,
+ new SubscriptionNotificationController.LocalDateTimeTypeAdapter()).create();
vnfmSimulatorCallbackUrl = getBaseUrl(port) + PACKAGE_MANAGEMENT_BASE_URL + NOTIFICATION_ENDPOINT;
+ testRestTemplate = new TestRestTemplate(
+ new RestTemplateBuilder().additionalMessageConverters(new GsonHttpMessageConverter(gson)));
}
@After
new InlineResponse201().id("subscriptionId").filter(new SubscriptionsFilter1())
.callbackUri("callbackUri");
- mockRestServiceServer.expect(requestTo(VNFM_ADAPTER_SUBSCRIPTION_ENDPOINT)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(SOL003_SUBSCRIPTION_URL)).andExpect(method(HttpMethod.POST))
.andExpect(content().json(gson.toJson(pkgmSubscriptionRequest)))
.andRespond(withSuccess(gson.toJson(inlineResponse), APPLICATION_JSON));
new InlineResponse201().id("subscriptionId").filter(new SubscriptionsFilter1())
.callbackUri("callbackUri");
- mockRestServiceServer.expect(requestTo(VNFM_ADAPTER_SUBSCRIPTION_ENDPOINT)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(SOL003_SUBSCRIPTION_URL)).andExpect(method(HttpMethod.POST))
.andExpect(content().json(gson.toJson(pkgmSubscriptionRequest)))
.andRespond(withSuccess(gson.toJson(inlineResponse), APPLICATION_JSON));
final VnfPackageOnboardingNotification vnfPackageOnboardingNotification =
gson.fromJson(getNotification(VNFPACKAGEONBOARDINGNOTIFICATION),
VnfPackageOnboardingNotification.class);
- final LocalDateTime timestamp = LocalDateTime.of(2020, 1, 1, 1, 1, 1, 1);
- vnfPackageOnboardingNotification.setTimeStamp(timestamp);
final ResponseEntity<?> responseEntity = postNotification(vnfPackageOnboardingNotification);
assertEquals(HttpStatus.NO_CONTENT, responseEntity.getStatusCode());
}