use of dk.dbc.search.solrdocstore.jpa.IndexKeysList in project solr-document-store by DBCDK.
the class BibliographicBeanIT method newRecordWhereSupersedesIsAlreadySet.
@Test
public void newRecordWhereSupersedesIsAlreadySet() throws Exception {
Response r;
String a870970 = makeBibliographicRequestJson(870970, e -> {
e.setBibliographicRecordId("a");
});
r = env().getPersistenceContext().run(() -> bean.addBibliographicKeys(false, a870970));
assertThat(r.getStatus(), is(200));
// Setup holding pointint to 870970:a
env().getPersistenceContext().run(() -> {
em.persist(new HoldingsItemEntity(700000, "a", new IndexKeysList(), "T#1"));
});
env().getPersistenceContext().run(() -> {
em.persist(new HoldingsToBibliographicEntity(700000, "a", 870970, true));
});
String b870970 = makeBibliographicRequestJson(870970, e -> {
e.setBibliographicRecordId("b");
e.setSupersedes(Arrays.asList("a"));
});
r = env().getPersistenceContext().run(() -> bean.addBibliographicKeys(false, b870970));
assertThat(r.getStatus(), is(200));
// Not really nessecary
String a870970d = makeBibliographicRequestJson(870970, e -> {
e.setDeleted(true);
e.setBibliographicRecordId("a");
});
r = env().getPersistenceContext().run(() -> bean.addBibliographicKeys(false, a870970d));
assertThat(r.getStatus(), is(200));
HoldingsToBibliographicEntity h2bBefore = env().getPersistenceContext().run(() -> {
return em.find(HoldingsToBibliographicEntity.class, new HoldingsToBibliographicKey(700000, "a"));
});
Assert.assertEquals(new HoldingsToBibliographicEntity(700000, "a", 870970, "b", true), h2bBefore);
String b70000 = makeBibliographicRequestJson(700000, e -> {
e.setBibliographicRecordId("b");
});
r = env().getPersistenceContext().run(() -> bean.addBibliographicKeys(false, b70000));
assertThat(r.getStatus(), is(200));
HoldingsToBibliographicEntity h2bAfter = env().getPersistenceContext().run(() -> {
return em.find(HoldingsToBibliographicEntity.class, new HoldingsToBibliographicKey(700000, "a"));
});
Assert.assertEquals(new HoldingsToBibliographicEntity(700000, "a", 700000, "b", true), h2bAfter);
}
use of dk.dbc.search.solrdocstore.jpa.IndexKeysList in project solr-document-store by DBCDK.
the class DocumentRetrieveBeanIT method newCommonRecordWithExistingHoldings.
@Test
public void newCommonRecordWithExistingHoldings() throws Exception {
em.merge(new BibliographicEntity(300000, "clazzifier", "12345678", "id#1", "work:0", "unit:0", false, new IndexKeys(), "T1"));
em.merge(new HoldingsItemEntity(300101, "12345678", new IndexKeysList(), "T2"));
em.merge(new HoldingsItemEntity(300102, "12345678", new IndexKeysList(), "T3"));
em.merge(new HoldingsToBibliographicEntity(300101, "12345678", 300000, false));
em.merge(new HoldingsToBibliographicEntity(300102, "12345678", 300000, false));
DocumentRetrieveResponse doc = env().getPersistenceContext().run(() -> bean.getDocumentWithHoldingsitems(300000, "clazzifier", "12345678"));
assertThat(doc.bibliographicRecord.getAgencyId(), is(300000));
assertThat(doc.bibliographicRecord.getBibliographicRecordId(), is("12345678"));
assertThat(doc.holdingsItemRecords.size(), is(2));
}
use of dk.dbc.search.solrdocstore.jpa.IndexKeysList in project solr-document-store by DBCDK.
the class HoldingsItemEntityIT method loadEntity.
@Test
public void loadEntity() throws Exception {
executeScriptResource("/entityTestData.sql");
EntityManager em = env().getEntityManager();
AgencyItemKey key = new AgencyItemKey(300, "4321");
HoldingsItemEntity be = env().getPersistenceContext().run(() -> em.find(HoldingsItemEntity.class, key));
assertThat(be.getAgencyId(), is(300));
assertThat(be.getBibliographicRecordId(), is("4321"));
IndexKeysList expected = new IndexKeysList();
IndexKeys doc1 = new IndexKeys();
doc1.put("title", Collections.singletonList("unix bogen"));
doc1.put("id", Collections.singletonList("argle"));
expected.add(doc1);
IndexKeys doc2 = new IndexKeys();
doc2.put("title", Collections.singletonList("unix bogen"));
doc2.put("id", Collections.singletonList("argle"));
doc2.put("dyr", Collections.singletonList("hest"));
expected.add(doc2);
assertThat(be.getIndexKeys(), is(expected));
assertThat(be.getTrackingId(), is("track"));
}
Aggregations