import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.onap.so.adapters.vnfmadapter.Constants.ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL;
+import static org.onap.so.adapters.vnfmadapter.common.CommonConstants.ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL;
import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_CLASS;
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.*;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.header;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.jsonPath;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
import java.net.URI;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.so.adapters.vnfmadapter.Constants;
-import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
+import org.onap.so.adapters.vnfmadapter.PackageManagementConstants;
import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.NOTIFICATIONLINKSERIALIZER;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgChangeNotification;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgOnboardingNotification;
-import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgmLinks;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthenticationParamsBasic;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthenticationParamsOauth2ClientCredentials;
+import org.onap.so.adapters.vnfmadapter.etsicatalog.notification.model.NOTIFICATIONLINKSERIALIZER;
+import org.onap.so.adapters.vnfmadapter.etsicatalog.notification.model.PkgChangeNotification;
+import org.onap.so.adapters.vnfmadapter.etsicatalog.notification.model.PkgOnboardingNotification;
+import org.onap.so.adapters.vnfmadapter.etsicatalog.notification.model.PkgmLinks;
+import org.onap.so.adapters.vnfmadapter.packagemanagement.model.PkgmSubscriptionRequest;
+import org.onap.so.adapters.vnfmadapter.packagemanagement.model.SubscriptionsAuthentication;
+import org.onap.so.adapters.vnfmadapter.packagemanagement.model.SubscriptionsAuthenticationParamsBasic;
+import org.onap.so.adapters.vnfmadapter.packagemanagement.model.SubscriptionsAuthenticationParamsOauth2ClientCredentials;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageChangeNotification;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageOnboardingNotification;
import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
-import org.springframework.http.*;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
*
*/
@RunWith(SpringRunner.class)
-@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
@DirtiesContext(classMode = BEFORE_CLASS)
public class EtsiSubscriptionNotificationControllerTest {
@Autowired
@Qualifier(CONFIGURABLE_REST_TEMPLATE)
private RestTemplate restTemplate;
- private MockRestServiceServer mockRestServer;
+ private MockRestServiceServer mockRestServiceServer;
@Autowired
private TestRestTemplate testRestTemplate;
@Before
public void setUp() {
- mockRestServer = MockRestServiceServer.bindTo(restTemplate).build();
+ mockRestServiceServer = MockRestServiceServer.bindTo(restTemplate).build();
basicHttpHeadersProvider = new BasicHttpHeadersProvider();
- cache = cacheServiceProvider.getCache(Constants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE);
+ cache = cacheServiceProvider.getCache(PackageManagementConstants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE);
cache.clear();
}
@After
public void tearDown() {
+ mockRestServiceServer.reset();
cache.clear();
}
final PkgOnboardingNotification notification = buildPkgOnboardingNotification();
final String notificationString = gson.toJson(notification);
- mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
.andExpect(jsonPath("$.id").value(NOTIFICATION_ID))
.andExpect(jsonPath("$.notificationType")
.value(VnfPackageOnboardingNotification.NotificationTypeEnum.VNFPACKAGEONBOARDINGNOTIFICATION
final PkgOnboardingNotification notification = buildPkgOnboardingNotification();
final String notificationString = gson.toJson(notification);
- mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
.andRespond(withStatus(HttpStatus.BAD_REQUEST));
final ResponseEntity<?> response = sendHttpPost(notificationString);
final PkgOnboardingNotification notification = buildPkgOnboardingNotification();
final String notificationString = gson.toJson(notification);
- mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
.andRespond(withStatus(HttpStatus.MOVED_PERMANENTLY));
final ResponseEntity<?> response = sendHttpPost(notificationString);
final PkgOnboardingNotification notification = buildPkgOnboardingNotification();
final String notificationString = gson.toJson(notification);
- mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
.andRespond(withStatus(HttpStatus.NOT_FOUND));
final ResponseEntity<?> response = sendHttpPost(notificationString);
final PkgOnboardingNotification notification = buildPkgOnboardingNotification();
final String notificationString = gson.toJson(notification);
- mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
.andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
final ResponseEntity<?> response = sendHttpPost(notificationString);
final PkgChangeNotification notification = buildPkgChangeNotification();
final String notificationString = gson.toJson(notification);
- mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
.andExpect(jsonPath("$.id").value(NOTIFICATION_ID))
.andExpect(jsonPath("$.notificationType").value(
VnfPackageChangeNotification.NotificationTypeEnum.VNFPACKAGECHANGENOTIFICATION.getValue()))
final PkgChangeNotification notification = buildPkgChangeNotification();
final String notificationString = gson.toJson(notification);
- mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
.andRespond(withStatus(HttpStatus.BAD_REQUEST));
final ResponseEntity<?> response = sendHttpPost(notificationString);
final PkgChangeNotification notification = buildPkgChangeNotification();
final String notificationString = gson.toJson(notification);
- mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
.andRespond(withStatus(HttpStatus.NOT_FOUND));
final ResponseEntity<?> response = sendHttpPost(notificationString);
final PkgChangeNotification notification = buildPkgChangeNotification();
final String notificationString = gson.toJson(notification);
- mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
.andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR));
final ResponseEntity<?> response = sendHttpPost(notificationString);
final PkgOnboardingNotification notification = buildPkgOnboardingNotification();
final String notificationString = gson.toJson(notification);
- mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
.andExpect(jsonPath("$.id").value(NOTIFICATION_ID))
.andExpect(jsonPath("$.notificationType")
.value(VnfPackageOnboardingNotification.NotificationTypeEnum.VNFPACKAGEONBOARDINGNOTIFICATION
final PkgChangeNotification notification = buildPkgChangeNotification();
final String notificationString = gson.toJson(notification);
- mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
.andExpect(header("Authorization", EXPECTED_BASIC_AUTHORIZATION))
.andRespond(withStatus(HttpStatus.UNAUTHORIZED));
final PkgChangeNotification notification = buildPkgChangeNotification();
final String notificationString = gson.toJson(notification);
- mockRestServer.expect(requestTo(TOKEN_ENDPOINT)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(TOKEN_ENDPOINT)).andExpect(method(HttpMethod.POST))
.andExpect(header("Authorization", EXPECTED_BASIC_AUTHORIZATION))
.andRespond(withSuccess(JSON_TOKEN, MediaType.APPLICATION_JSON));
- mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST))
.andExpect(header("Authorization", EXPECTED_OAUTH_AUTHORIZATION))
.andExpect(jsonPath("$.id").value(NOTIFICATION_ID))
.andExpect(jsonPath("$.notificationType").value(
final PkgChangeNotification notification = buildPkgChangeNotification();
final String notificationString = gson.toJson(notification);
- mockRestServer.expect(requestTo(TOKEN_ENDPOINT)).andExpect(method(HttpMethod.POST))
+ mockRestServiceServer.expect(requestTo(TOKEN_ENDPOINT)).andExpect(method(HttpMethod.POST))
.andExpect(header("Authorization", EXPECTED_BASIC_AUTHORIZATION)).andRespond(withSuccess());
final ResponseEntity<?> response = sendHttpPost(notificationString);