@Test public void removeReference() throws IOException { Object value1 = new Object(); EnrichmentTag tag1 = new EnrichmentTag(); tag1.setValue("et1value"); tag1.setJudgmentId(7); Object value2 = new Object(); EnrichmentTag tag2 = new EnrichmentTag(); tag2.setValue("et2value"); tag2.setJudgmentId(8); Query query = mock(Query.class); when(query.getResultList()).thenReturn(Lists.newArrayList(tag1, tag2)); when(tagModifyingJudgmentReferenceRemover.buildSelectQuery()).thenReturn("query"); when(entityManager.createNativeQuery("query", EnrichmentTag.class)).thenReturn(query); when(jsonStringParser.parseAndValidate("et1value")).thenReturn(value1); when(jsonStringParser.parseAndValidate("et2value")).thenReturn(value2); when(jsonFormatter.formatObject(value1)).thenReturn("et1value_changed"); when(jsonFormatter.formatObject(value2)).thenReturn("et2value_changed"); tagModifyingJudgmentReferenceRemover.removeReferences(Lists.newArrayList(2L, 3L)); verify(entityManager).createNativeQuery("query", EnrichmentTag.class); verify(query).setParameter("judgmentIds", Lists.newArrayList("2", "3")); verify(tagModifyingJudgmentReferenceRemover).removeReference(value1, Lists.newArrayList(2L, 3L)); verify(tagModifyingJudgmentReferenceRemover).removeReference(value2, Lists.newArrayList(2L, 3L)); verify(judgmentRepository).markAsNotIndexed(Lists.newArrayList(7L, 8L)); assertEquals("et1value_changed", tag1.getValue()); assertEquals("et2value_changed", tag2.getValue()); }
protected abstract void removeReference(TAG_TYPE tagValue, List<Long> judgmentId);
TagModifyingJudgmentReferenceRemover implements TagJudgmentReferenceRemover { protected abstract void removeReference(TAG_TYPE tagValue, List<Long> judgmentId); }
TagModifyingJudgmentReferenceRemover implements TagJudgmentReferenceRemover { protected abstract void removeReference(TAG_TYPE tagValue, List<Long> judgmentId);  }
TagModifyingJudgmentReferenceRemover implements TagJudgmentReferenceRemover { protected abstract void removeReference(TAG_TYPE tagValue, List<Long> judgmentId);  @Override void removeReferences(List<Long> judgmentIds); @Autowired void setEntityManager(EntityManager entityManager); @Autowired void setEnrichmentTagRepository(EnrichmentTagRepository enrichmentTagRepository); @Autowired void setJudgmentRepository(JudgmentRepository judgmentRepository); @Autowired void setJsonStringParser(JsonStringParser<TAG_TYPE> jsonStringParser); @Autowired void setJsonFormatter(JsonFormatter jsonFormatter); }
TagModifyingJudgmentReferenceRemover implements TagJudgmentReferenceRemover { protected abstract void removeReference(TAG_TYPE tagValue, List<Long> judgmentId);  @Override void removeReferences(List<Long> judgmentIds); @Autowired void setEntityManager(EntityManager entityManager); @Autowired void setEnrichmentTagRepository(EnrichmentTagRepository enrichmentTagRepository); @Autowired void setJudgmentRepository(JudgmentRepository judgmentRepository); @Autowired void setJsonStringParser(JsonStringParser<TAG_TYPE> jsonStringParser); @Autowired void setJsonFormatter(JsonFormatter jsonFormatter);  }