### Question:
MotownVasPublisherService implements VasPublisherService { @Override public UnsubscribeResponse unsubscribe(@WebParam(partName = "parameters", name = "unsubscribeRequest", targetNamespace = VAS_NAMESPACE) UnsubscribeRequest parameters, @WebParam(partName = "SubscriberIdentity", name = "subscriberIdentity", targetNamespace = VAS_NAMESPACE, header = true) String subscriberIdentity) { LOG.info("Unsubscribing {}", subscriberIdentity); UnsubscribeResponse unsubscribeResponse = new UnsubscribeResponse(); try { Subscription subscription = subscriptionRepository.findBySubscriptionId(parameters.getSubscriptionId()); if (subscription != null) { subscriptionRepository.delete(subscription); unsubscribeResponse.setStatus(SubscribeStatus.ACCEPTED); } else { LOG.warn("Unable to unsubscribe unkown subscription {}", subscriberIdentity); unsubscribeResponse.setStatus(SubscribeStatus.REJECTED); } } catch (Exception e) { LOG.error("Unsubscribing of {} failed", subscriberIdentity, e); unsubscribeResponse.setStatus(SubscribeStatus.REJECTED); } return unsubscribeResponse; }  @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 unsubscribeKnownSubscriptionValidateResponse() { String subscriptionId = subscribeTestSubscriber(); UnsubscribeRequest request = new UnsubscribeRequest(); request.setSubscriptionId(subscriptionId); UnsubscribeResponse response = service.unsubscribe(request, SUBSCRIBER_IDENTITY); assertEquals(SubscribeStatus.ACCEPTED, response.getStatus()); }
@Test public void unsubscribeUnknownSubscriptionValidateResponse() { String unknownSubscriptionId = "unknown"; UnsubscribeRequest request = new UnsubscribeRequest(); request.setSubscriptionId(unknownSubscriptionId); UnsubscribeResponse response = service.unsubscribe(request, SUBSCRIBER_IDENTITY); assertEquals(SubscribeStatus.REJECTED, response.getStatus()); }
@Test public void unsubscribeKnownSubscriptionTwiceValidateResponse() { String subscriptionId = subscribeTestSubscriber(); UnsubscribeRequest request = new UnsubscribeRequest(); request.setSubscriptionId(subscriptionId); service.unsubscribe(request, SUBSCRIBER_IDENTITY); UnsubscribeResponse response = service.unsubscribe(request, SUBSCRIBER_IDENTITY); assertEquals(SubscribeStatus.REJECTED, response.getStatus()); }
@Test public void unsubscribeKnownSubscriptioValidateRepository() { String subscriptionId = subscribeTestSubscriber(); UnsubscribeRequest request = new UnsubscribeRequest(); request.setSubscriptionId(subscriptionId); service.unsubscribe(request, SUBSCRIBER_IDENTITY); assertNull(subscriptionRepository.findBySubscriberIdentityAndDeliveryAddress(SUBSCRIBER_IDENTITY, DELIVERY_ADDRESS)); }