use of dk.dbc.search.solrdocstore.response.OpenAgencyStatusResponse in project solr-document-store by DBCDK.
the class OpenAgencyStatusBeanIT method getStatusOk.
@Test
public void getStatusOk() throws Exception {
System.out.println("getStatusOk");
OpenAgencyStatusResponse status = env().getPersistenceContext().run(() -> {
em.persist(new OpenAgencyEntity(711100, LibraryType.FBS, true, true, true));
return (OpenAgencyStatusResponse) openAgencyStatus.getStatus().getEntity();
});
assertThat(status.ok, is(true));
}
use of dk.dbc.search.solrdocstore.response.OpenAgencyStatusResponse in project solr-document-store by DBCDK.
the class OpenAgencyStatusBean method getStatus.
@GET
@Path("status")
@Produces(MediaType.APPLICATION_JSON)
public Response getStatus() {
OpenAgencyStatusResponse resp = new OpenAgencyStatusResponse();
List<OpenAgencyEntity> entries = entityManager.createQuery("SELECT oa FROM OpenAgencyEntity oa WHERE oa.valid <> True", OpenAgencyEntity.class).getResultList();
for (OpenAgencyEntity solrDocStore : entries) {
OpenAgencyEntity openAgency = proxy.loadOpenAgencyEntry(solrDocStore.getAgencyId());
resp.states.put(solrDocStore.getAgencyId(), new OpenAgencyStatusResponse.Diag(solrDocStore, openAgency));
}
resp.ok = resp.states.isEmpty();
return Response.ok(resp).header("Access-Control-Allow-Origin", "*").build();
}
use of dk.dbc.search.solrdocstore.response.OpenAgencyStatusResponse in project solr-document-store by DBCDK.
the class OpenAgencyStatusBeanIT method getStatusNotOk.
@Test
public void getStatusNotOk() throws Exception {
System.out.println("getStatusNotOk");
OpenAgencyStatusResponse status = env().getPersistenceContext().run(() -> {
OpenAgencyEntity entity = new OpenAgencyEntity(711100, LibraryType.FBS, true, false, false);
entity.setValid(false);
em.persist(entity);
return (OpenAgencyStatusResponse) openAgencyStatus.getStatus().getEntity();
});
assertThat(status.ok, is(false));
OpenAgencyStatusResponse.Diag diag = status.states.get(711100);
assertThat(diag.openAgency, not(is(diag.solrDocStore)));
}
Aggregations