### Question:
MotownVasPublisherService implements VasPublisherService { @Override public SubscribeResponse subscribe(@WebParam(partName = "parameters", name = "subscribeRequest", targetNamespace = VAS_NAMESPACE) SubscribeRequest parameters, @WebParam(partName = "SubscriberIdentity", name = "subscriberIdentity", targetNamespace = VAS_NAMESPACE, header = true) String subscriberIdentity) { LOG.info("Subscribing {}", subscriberIdentity); SubscribeResponse subscribeResponse = new SubscribeResponse(); try { String deliveryAddress = parameters.getDeliveryAddress(); if (subscriptionRepository.findBySubscriberIdentityAndDeliveryAddress(subscriberIdentity, deliveryAddress) == null) { Subscription subscription = new Subscription(subscriberIdentity, deliveryAddress); subscriptionRepository.insert(subscription); subscribeResponse.setSubscriptionId(subscription.getSubscriptionId()); subscribeResponse.setStatus(SubscribeStatus.ACCEPTED); } else { subscribeResponse.setStatus(SubscribeStatus.DUPLICATE_IGNORED); } } catch (Exception e) { LOG.error("Subscription failed", e); subscribeResponse.setStatus(SubscribeStatus.REJECTED); } return subscribeResponse; }  @Override SubscribeResponse subscribe(@WebParam(partName = "parameters", name = "subscribeRequest", targetNamespace = VAS_NAMESPACE) SubscribeRequest parameters, @WebParam(partName = "SubscriberIdentity", name = "subscriberIdentity", targetNamespace = VAS_NAMESPACE, header = true) String subscriberIdentity); @Override GetChargePointInfoResponse getChargePointInfo(@WebParam(partName = "parameters", name = "getChargePointInfoRequest", targetNamespace = VAS_NAMESPACE) GetChargePointInfoRequest parameters, @WebParam(partName = "SubscriberIdentity", name = "subscriberIdentity", targetNamespace = VAS_NAMESPACE, header = true) String subscriberIdentity); @Override UnsubscribeResponse unsubscribe(@WebParam(partName = "parameters", name = "unsubscribeRequest", targetNamespace = VAS_NAMESPACE) UnsubscribeRequest parameters, @WebParam(partName = "SubscriberIdentity", name = "subscriberIdentity", targetNamespace = VAS_NAMESPACE, header = true) String subscriberIdentity); void setSubscriptionRepository(SubscriptionRepository subscriptionRepository); void setChargingStationRepository(ChargingStationRepository chargingStationRepository); void setVasConversionService(VasConversionService vasConversionService); static final String VAS_NAMESPACE; }### Answer:
@Test public void subscribeAcceptedValidateResponse() { SubscribeRequest request = new SubscribeRequest(); request.setDeliveryAddress(DELIVERY_ADDRESS); SubscribeResponse response = service.subscribe(request, SUBSCRIBER_IDENTITY); assertEquals(SubscribeStatus.ACCEPTED, response.getStatus()); assertNotNull(response.getSubscriptionId()); }
@Test public void subscribeDuplicateIgnoredValidateResponse() { SubscribeRequest request = new SubscribeRequest(); request.setDeliveryAddress(DELIVERY_ADDRESS); service.subscribe(request, SUBSCRIBER_IDENTITY); SubscribeResponse response = service.subscribe(request, SUBSCRIBER_IDENTITY); assertEquals(SubscribeStatus.DUPLICATE_IGNORED, response.getStatus()); assertNull(response.getSubscriptionId()); }
@Test public void subscribeDuplicateIdentityValidateAcceptedResponse() { SubscribeRequest request = new SubscribeRequest(); request.setDeliveryAddress(DELIVERY_ADDRESS); service.subscribe(request, SUBSCRIBER_IDENTITY); request.setDeliveryAddress(OTHER_DELIVERY_ADDRESS); SubscribeResponse response = service.subscribe(request, SUBSCRIBER_IDENTITY); assertEquals(SubscribeStatus.ACCEPTED, response.getStatus()); }
@Test public void subscribeValidateSavedSubscription() { SubscribeRequest request = new SubscribeRequest(); request.setDeliveryAddress(DELIVERY_ADDRESS); service.subscribe(request, SUBSCRIBER_IDENTITY); assertNotNull(subscriptionRepository.findBySubscriberIdentityAndDeliveryAddress(SUBSCRIBER_IDENTITY, DELIVERY_ADDRESS)); }