private SensorDao createDao() {
    this.oldSensor = Mockito.mock(Sensor.class);
    Map<String, Object> props = new HashMap<>();
    props.put("fuelType", "diesel");
    props.put("constructionYear", 2015);
    props.put("engineDisplacement", 1234);
    props.put("model", "DiTO ");
    props.put("manufacturer", "vITO ");
    String id = "51ffab4fe4b058cd3d654006";

    Mockito.when(oldSensor.getIdentifier()).thenReturn(id);
    Mockito.when(oldSensor.getProperties()).thenReturn(props);

    SensorDao dao = Mockito.mock(SensorDao.class);
    Mockito.when(dao.get(Mockito.any(SensorFilter.class)))
        .thenReturn(Sensors.from(Arrays.asList(new Sensor[] {oldSensor})).build());
    Mockito.when(dao.getByIdentifier(id)).thenReturn(oldSensor);

    return dao;
  }
Ejemplo n.º 2
0
 @Override
 protected Sensors createPaginatedIterable(Iterable<MongoSensor> i, Pagination p, long count) {
   return Sensors.from(i).withElements(count).withPagination(p).build();
 }