return query;
}
- public static Subscriber createFromRequest(Subscription request) {
+ public static Subscriber createFromSubscription(Subscription request) {
Subscriber sub = new Subscriber();
sub.setCallback(request.getCallback());
*/
private static Object filterServiceOrder(final ServiceOrder serviceOrder) {
- Object filteredServiceOrder;
+ Object filteredServiceOrder = null;
- JsonRepresentation jsonRepresentation = new JsonRepresentation();
- jsonRepresentation.add("id").add("href").add("externalId").add("state").add("orderDate").add
+ if (serviceOrder != null) {
+ JsonRepresentation jsonRepresentation = new JsonRepresentation();
+ jsonRepresentation.add("id").add("href").add("externalId").add("state").add("orderDate").add
("completionDateTime").add("orderItem");
- filteredServiceOrder = JacksonFilter.createNode(serviceOrder, jsonRepresentation);
+ filteredServiceOrder = JacksonFilter.createNode(serviceOrder, jsonRepresentation);
+ }
return filteredServiceOrder;
}
import org.onap.nbi.apis.hub.model.Subscriber;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.Async;
public class NotifierService {
private final Logger logger = LoggerFactory.getLogger(NotifierService.class);
+ @Autowired
+ RestTemplate restTemplate;
+
@Async
public void run(Subscriber subscriber, @Valid Event event) {
- ResponseEntity<String> re = new RestTemplate().postForEntity(subscriber.getCallback(), event, String.class);
+ ResponseEntity<String> re = restTemplate.postForEntity(subscriber.getCallback(), event, String.class);
if (re.getStatusCode() == HttpStatus.OK) logger.debug("FAILED");
}
}
}
public Subscriber createSubscription(Subscription subscription){
- Subscriber sub = Subscriber.createFromRequest(subscription);
+ Subscriber sub = Subscriber.createFromSubscription(subscription);
return subscriberRepository.save(sub);
}
*/
package org.onap.nbi.apis.assertions;
+import org.onap.nbi.apis.hub.model.Event;
+import org.onap.nbi.apis.hub.model.EventType;
import org.onap.nbi.apis.hub.model.Subscription;
+import java.util.Date;
+import java.util.UUID;
+
public class HubAssertions {
public static Subscription createServiceOrderCreationSubscription(){
Subscription subscription = new Subscription();
subscription.setId("id");
- subscription.setCallback("http://localhost:8090");
+ subscription.setCallback("http://localhost:8080/test");
subscription.setQuery("eventType = ServiceOrderCreationNotification");
return subscription;
}
public static Subscription createServiceOrderStateChangeSubscription(){
Subscription subscription = new Subscription();
subscription.setId("id");
- subscription.setCallback("http://localhost:8090");
+ subscription.setCallback("http://localhost/test");
subscription.setQuery("eventType = ServiceOrderStateChangeNotification");
return subscription;
}
public static Subscription createServiceOrderItemStateChangeSubscription(){
Subscription subscription = new Subscription();
subscription.setId("id");
- subscription.setCallback("http://localhost:8090");
+ subscription.setCallback("http://localhost/test");
subscription.setQuery("eventType = ServiceOrderItemStateChangeNotification");
return subscription;
}
+
+ public static Event createFakeEvent() {
+ Event event = new Event();
+ event.setEventId(UUID.randomUUID().toString());
+ event.setEventDate(new Date());
+ event.setEventType(EventType.SERVICE_ORDER_CREATION.value());
+ return event;
+ }
}