Search in sources :

Example 1 with OpenAgencyStatusResponse

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));
}
Also used : OpenAgencyStatusResponse(dk.dbc.search.solrdocstore.response.OpenAgencyStatusResponse) OpenAgencyEntity(dk.dbc.search.solrdocstore.jpa.OpenAgencyEntity) Test(org.junit.Test)

Example 2 with OpenAgencyStatusResponse

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();
}
Also used : OpenAgencyStatusResponse(dk.dbc.search.solrdocstore.response.OpenAgencyStatusResponse) OpenAgencyEntity(dk.dbc.search.solrdocstore.jpa.OpenAgencyEntity) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with OpenAgencyStatusResponse

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)));
}
Also used : OpenAgencyStatusResponse(dk.dbc.search.solrdocstore.response.OpenAgencyStatusResponse) OpenAgencyEntity(dk.dbc.search.solrdocstore.jpa.OpenAgencyEntity) Test(org.junit.Test)

Aggregations

OpenAgencyEntity (dk.dbc.search.solrdocstore.jpa.OpenAgencyEntity)3 OpenAgencyStatusResponse (dk.dbc.search.solrdocstore.response.OpenAgencyStatusResponse)3 Test (org.junit.Test)2 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1