@Test public void postNewRegisterContext() throws Exception { when(localRegistrations.updateRegistrationContext(any())).thenReturn("12345678"); ListenableFuture<RegisterContextResponse> responseFuture = Mockito.mock(ListenableFuture.class); doNothing().when(responseFuture).addCallback(any(), any()); when(ngsiClient.registerContext(any(), eq(null), any())).thenReturn(responseFuture); mockMvc.perform(post("/v1/registerContext") .content(json(mapper, createRegisterContextTemperature())) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(MockMvcResultMatchers.jsonPath("$.registrationId").value("12345678")); }
@Override public RegisterContextResponse registerContext(final RegisterContext register) throws RegistrationException, RegistrationPersistenceException { logger.debug("<= registerContext with id:{} duration:{}", register.getRegistrationId(), register.getDuration()); RegisterContextResponse registerContextLocalResponse = new RegisterContextResponse(); registerContextLocalResponse.setRegistrationId(localRegistrations.updateRegistrationContext(register)); return registerContextLocalResponse; }
NgsiController extends NgsiBaseController { @Override public RegisterContextResponse registerContext(final RegisterContext register) throws RegistrationException, RegistrationPersistenceException { logger.debug("<= registerContext with id:{} duration:{}", register.getRegistrationId(), register.getDuration()); RegisterContextResponse registerContextLocalResponse = new RegisterContextResponse(); registerContextLocalResponse.setRegistrationId(localRegistrations.updateRegistrationContext(register)); return registerContextLocalResponse; } }
NgsiController extends NgsiBaseController { @Override public RegisterContextResponse registerContext(final RegisterContext register) throws RegistrationException, RegistrationPersistenceException { logger.debug("<= registerContext with id:{} duration:{}", register.getRegistrationId(), register.getDuration()); RegisterContextResponse registerContextLocalResponse = new RegisterContextResponse(); registerContextLocalResponse.setRegistrationId(localRegistrations.updateRegistrationContext(register)); return registerContextLocalResponse; }  }
NgsiController extends NgsiBaseController { @Override public RegisterContextResponse registerContext(final RegisterContext register) throws RegistrationException, RegistrationPersistenceException { logger.debug("<= registerContext with id:{} duration:{}", register.getRegistrationId(), register.getDuration()); RegisterContextResponse registerContextLocalResponse = new RegisterContextResponse(); registerContextLocalResponse.setRegistrationId(localRegistrations.updateRegistrationContext(register)); return registerContextLocalResponse; }  @Override RegisterContextResponse registerContext(final RegisterContext register); @Override UpdateContextResponse updateContext(final UpdateContext update); @Override QueryContextResponse queryContext(final QueryContext query); @Override SubscribeContextResponse subscribeContext(final SubscribeContext subscribe); @Override UpdateContextSubscriptionResponse updateContextSubscription(final UpdateContextSubscription updateContextSubscription); @Override UnsubscribeContextResponse unsubscribeContext(final UnsubscribeContext unsubscribe); @ExceptionHandler(RegistrationException.class) ResponseEntity<Object> registrationExceptionHandler(HttpServletRequest req, RegistrationException registrationException); @ExceptionHandler(MissingRemoteBrokerException.class) ResponseEntity<Object> missingRemoteBrokerExceptionHandler(HttpServletRequest req, MissingRemoteBrokerException missingRemoteBrokerException); @ExceptionHandler(SubscriptionException.class) ResponseEntity<Object> subscriptionExceptionHandler(HttpServletRequest req, SubscriptionException subscriptionException); @ExceptionHandler(SubscriptionPersistenceException.class) ResponseEntity<Object> subscriptionPersistenceExceptionHandler(HttpServletRequest req, SubscriptionPersistenceException subscriptionPersistenceException); @ExceptionHandler(RegistrationPersistenceException.class) ResponseEntity<Object> registrationPersistenceExceptionHandler(HttpServletRequest req, RegistrationPersistenceException registrationPersistenceException); }
NgsiController extends NgsiBaseController { @Override public RegisterContextResponse registerContext(final RegisterContext register) throws RegistrationException, RegistrationPersistenceException { logger.debug("<= registerContext with id:{} duration:{}", register.getRegistrationId(), register.getDuration()); RegisterContextResponse registerContextLocalResponse = new RegisterContextResponse(); registerContextLocalResponse.setRegistrationId(localRegistrations.updateRegistrationContext(register)); return registerContextLocalResponse; }  @Override RegisterContextResponse registerContext(final RegisterContext register); @Override UpdateContextResponse updateContext(final UpdateContext update); @Override QueryContextResponse queryContext(final QueryContext query); @Override SubscribeContextResponse subscribeContext(final SubscribeContext subscribe); @Override UpdateContextSubscriptionResponse updateContextSubscription(final UpdateContextSubscription updateContextSubscription); @Override UnsubscribeContextResponse unsubscribeContext(final UnsubscribeContext unsubscribe); @ExceptionHandler(RegistrationException.class) ResponseEntity<Object> registrationExceptionHandler(HttpServletRequest req, RegistrationException registrationException); @ExceptionHandler(MissingRemoteBrokerException.class) ResponseEntity<Object> missingRemoteBrokerExceptionHandler(HttpServletRequest req, MissingRemoteBrokerException missingRemoteBrokerException); @ExceptionHandler(SubscriptionException.class) ResponseEntity<Object> subscriptionExceptionHandler(HttpServletRequest req, SubscriptionException subscriptionException); @ExceptionHandler(SubscriptionPersistenceException.class) ResponseEntity<Object> subscriptionPersistenceExceptionHandler(HttpServletRequest req, SubscriptionPersistenceException subscriptionPersistenceException); @ExceptionHandler(RegistrationPersistenceException.class) ResponseEntity<Object> registrationPersistenceExceptionHandler(HttpServletRequest req, RegistrationPersistenceException registrationPersistenceException);  }