CommitHistoryStoreImpl implements CommitHistoryStore { @Inject public CommitHistoryStoreImpl(@Named("DefaultEntityManagerFactory") EntityManagerFactory entityManagerFactory) { super(); this.entityManagerFactory = entityManagerFactory; } @Inject  CommitHistoryStoreImpl(@Named("DefaultEntityManagerFactory") EntityManagerFactory entityManagerFactory); @Override void add(CommitHistoryItem item, String ontology); @Override void update(CommitHistoryItem item, String ontology); @Override void remove(final CommitHistoryItem item, final String ontology); @Override CommitHistory loadHistory(String ontology); @Override List<CommitHistoryItem> loadHistory(String ontology, boolean committed); @Override List<CommitHistoryItem> load(String ontology, Date from, Date to); @Override List<CommitHistoryItem> load(List<Integer> itemIds); @Override List<CommitHistoryItem> getItemsForReview(String ontology); @Override List<Pair<String, String>> checkRecentCommits(String ontology, List<String> labels); @Override List<Pair<String, String>> checkRecentCommitIds(List<String> ids);  }
@Test public void testCommitHistoryStoreImpl() throws Exception { EntityManagerFactory emf = provider.createFactory(folder.newFolder(), EntityManagerFactoryProvider.HSQLDB, EntityManagerFactoryProvider.MODE_DEFAULT, "CommitHistory"); assertNotNull(emf); CommitHistoryStoreImpl store = new CommitHistoryStoreImpl(emf); assertNull(store.loadHistory("Test")); List<CommitHistoryItem> itemsForReview = store.getItemsForReview("Test"); assertNull(itemsForReview); CommitHistoryItem item1 = createTestItem(1, 0, 3); CommitHistoryItem item2 = createTestItem(2, 3, 1); CommitHistoryItem item3 = createTestItem(3, 4, 2); store.add(item1, "Test"); store.add(item2, "Test"); store.add(item3, "Test"); itemsForReview = store.getItemsForReview("Test"); assertEquals(3, itemsForReview.size()); itemsForReview = store.getItemsForReview("Test"); assertEquals(3, itemsForReview.size()); assertEqualsItem(item1, itemsForReview.get(0)); assertEqualsItem(item2, itemsForReview.get(1)); assertEqualsItem(item3, itemsForReview.get(2)); List<Pair<String, String>> existing = store.checkRecentCommits("Test", Arrays.asList("Term label 1", "Term label -1")); assertEquals(1, existing.size()); assertEquals("t:01", existing.get(0).getOne()); itemsForReview = store.getItemsForReview("Test"); assertEquals(3, itemsForReview.size()); final CommitHistoryItem change = itemsForReview.get(0); assertEqualsItem(item1, change); List<CommitedOntologyTerm> terms = change.getTerms(); for (CommitedOntologyTerm term : terms) { Frame f = CommitHistoryTools.translate(term.getId(), term.getObo()); String def = f.getTagValue(OboFormatTag.TAG_DEF, String.class); f.setClauses(Collections.singletonList(new Clause(OboFormatTag.TAG_DEF, "OBOSOLETE. "+def))); OboTools.removeAllRelations(f); term.setObo(OboWriterTools.writeFrame(f, null)); } store.update(change, "Test"); itemsForReview = store.getItemsForReview("Test"); assertEquals(3, itemsForReview.size()); }