ServiceRegistrationJpaImpl implements ServiceRegistration { public Long getId() { return id; } ServiceRegistrationJpaImpl();  ServiceRegistrationJpaImpl(HostRegistrationJpaImpl hostRegistration, String serviceType, String path);  ServiceRegistrationJpaImpl(HostRegistrationJpaImpl hostRegistration, String serviceType, String path,
          boolean jobProducer); Long getId(); void setId(Long id); @Override Date getOnlineFrom(); void setOnlineFrom(Date onlineFrom); @Override String getServiceType(); @Override String getPath(); void setPath(String path); @Override ServiceState getServiceState(); void setServiceState(ServiceState serviceState); void setServiceState(ServiceState state, int triggerJobSignature); @Override Date getStateChanged(); void setStateChanged(Date stateChanged); @Override int getWarningStateTrigger(); void setWarningStateTrigger(int warningStateTrigger); @Override int getErrorStateTrigger(); void setErrorStateTrigger(int errorStateTrigger); @Override boolean isActive(); void setActive(boolean isActive); @Override boolean isOnline(); void setOnline(boolean online); @Override boolean isJobProducer(); void setJobProducer(boolean isJobProducer); @Override boolean isInMaintenanceMode(); @Override String getHost(); HostRegistrationJpaImpl getHostRegistration(); void setHostRegistration(HostRegistrationJpaImpl hostRegistration); @PostLoad void postLoad(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void testQueryStatistics() throws Exception { HostRegistrationJpaImpl host = new HostRegistrationJpaImpl("http: 1, 1, true, false); ServiceRegistrationJpaImpl serviceReg = new ServiceRegistrationJpaImpl(host, "NOP", "/nop", false); Date now = new Date(); host = env.tx(Queries.persistOrUpdate(host)); serviceReg = env.tx(Queries.persistOrUpdate(serviceReg)); JpaJob job = env.tx(Queries.persistOrUpdate(createJob(now, serviceReg))); JpaJob jobYesterday = env.tx(Queries.persistOrUpdate(createJob(DateUtils.addDays(now, -1), serviceReg))); List<Object> statistic = env.tx( Queries.named.findAll("ServiceRegistration.statistics", P.p2("minDateCreated", now), P.p2("maxDateCreated", now))); Object[] stats = (Object[]) statistic.get(0); assertEquals(1, statistic.size()); assertEquals(5, stats.length); assertEquals(serviceReg.getId().longValue(), ((Number) stats[0]).longValue()); assertEquals(job.getStatus().ordinal(), ((Number) stats[1]).intValue()); assertEquals(1, ((Number) stats[2]).intValue()); assertEquals(500L, ((Number) stats[3]).longValue()); assertEquals(1000L, ((Number) stats[4]).longValue()); statistic = env.tx( Queries.named.findAll("ServiceRegistration.statistics", P.p2("minDateCreated", DateUtils.addDays(now, -3)), P.p2("maxDateCreated", DateUtils.addDays(now, -2)))); assertEquals(0, statistic.size()); }