@Before
  public void setup() {
    MockitoAnnotations.initMocks(this);
    AnalyticsResource resource = new AnalyticsResource();
    resource.setService(service);
    restUserMockMvc = MockMvcBuilders.standaloneSetup(resource).build();

    mapper = new ObjectMapper();
    testData = new ArrayList<AnalyticsLog>();

    app = new App();
    app.setName("Testapp");
    app.setId(5L);
    app.setDateCreated(new DateTime());
    app.setDateUpdated(new DateTime());
    app.setApplicationKey(UUID.randomUUID());

    secondApp = new App();
    secondApp.setName("Testapp 2");
    secondApp.setId(2L);
    secondApp.setDateCreated(new DateTime());
    secondApp.setDateUpdated(new DateTime());
    secondApp.setApplicationKey(UUID.randomUUID());

    event = new NotificationEvent();
    event.setName("Event 2");
    event.setId(1L);
    event.setMessage("Test");
    event.setTitle("test");
    event.setDateUpdated(new DateTime());
    event.setDateCreated(new DateTime());
    event.getApps().add(app);

    beacon = new Beacon();
    beacon.setName("Event 2");
    beacon.setId(1L);
    beacon.setDateUpdated(new DateTime());
    beacon.setDateCreated(new DateTime());

    AnalyticsLog log = new AnalyticsLog();
    log.setId(11L);
    log.setDateUpdated(new DateTime());
    log.setDateCreated(new DateTime());
    log.setOccuredEvent(event);
    log.setBeacon(beacon);
    log.setApp(app);

    AnalyticsLog secondLog = new AnalyticsLog();
    secondLog.setId(1212L);
    secondLog.setDateUpdated(new DateTime());
    secondLog.setDateCreated(new DateTime().minusDays(5));
    secondLog.setOccuredEvent(event);
    secondLog.setBeacon(beacon);
    secondLog.setApp(app);

    testData.add(log);
    testData.add(secondLog);
  }
  @Test
  public void testGetBeaconsStatistics() throws Exception {
    List<AnalyticsTransfer> list = new ArrayList<AnalyticsTransfer>();
    AnalyticsTransfer transfer = new AnalyticsTransfer();
    transfer.setId(beacon.getId());
    transfer.setName(beacon.getName());
    transfer.setCount(22);
    list.add(transfer);

    String value = mapper.writeValueAsString(list);
    DateTime from = new DateTime().minusDays(10);
    DateTime to = new DateTime().minusDays(3);
    when(service.beaconsTriggered(from, to)).thenReturn(list);
    DateTimeFormatter formatter = ISODateTimeFormat.dateTime();
    String requestString =
        "/client/analytics/beacons?from="
            + from.toString(formatter)
            + "&to="
            + to.toString(formatter);
    restUserMockMvc
        .perform(get(requestString).accept(MediaType.APPLICATION_JSON))
        .andExpect(status().isOk())
        .andExpect(content().string(value));
  }