예제 #1
0
  @Test
  public void updateMobileComponentsLocation() throws Exception {
    final List<SensorLocationElement> resources = generateRandomSensorLocationList();
    when(message.getLocations()).thenReturn(resources);

    final CatalogResponseMessage response = controller.updateMobileComponentsLocation(message);

    verify(sensorService, times(resources.size())).findByName(anyString(), anyString());
    verify(componentService).updateAll(anyCollectionOf(Component.class));
    Assert.assertEquals(CatalogResponseMessage.OK, response.getCode());
  }
예제 #2
0
  @Test
  public void updateMobileComponentsLocationWithError() throws Exception {
    final List<SensorLocationElement> resources = generateRandomList(SensorLocationElement.class);
    when(message.getLocations()).thenReturn(resources);
    doThrow(Exception.class).when(sensorService).findByName(anyString(), anyString());

    final CatalogResponseMessage response = controller.updateMobileComponentsLocation(message);

    verify(componentService, times(0)).updateAll(anyCollectionOf(Component.class));
    Assert.assertEquals(CatalogResponseMessage.INTERNAL_SERVER_ERROR, response.getCode());
  }
예제 #3
0
 public void writeResponse(
     final SentiloRequest request,
     final SentiloResponse response,
     final CatalogResponseMessage message)
     throws PlatformException {
   // To hide internal error code to client,we reset its value from the message
   message.setCode(null);
   writeInternal(message, response);
 }