@Test public void applyEnrichmentTag() throws Exception { String tagValueObject = "YYY"; Object modelObject = mock(Object.class); when(enrichmentTag.getValue()).thenReturn(tagValueObject); when(jsonStringParser.parseAndValidate(enrichmentTag.getValue())).thenReturn(tagValueObject); when(enrichmentTagValueConverter.convert(tagValueObject)).thenReturn(modelObject); defaultEnrichmentTagApplier.applyEnrichmentTag(judgment, enrichmentTag); verify(jsonStringParser).parseAndValidate(tagValueObject); verify(enrichmentTagValueConverter).convert(tagValueObject); verify(judgmentUpdater).addToJudgment(judgment, modelObject); verifyNoMoreInteractions(jsonStringParser, enrichmentTagValueConverter, judgmentUpdater); }
@Override public void applyEnrichmentTag(Judgment judgment, EnrichmentTag enrichmentTag) { Preconditions.checkNotNull(judgment); Preconditions.checkNotNull(enrichmentTag); Preconditions.checkArgument(handlesEnrichmentTagType(enrichmentTag.getTagType())); TAG_VALUE enrichmentTagValue; try { enrichmentTagValue = jsonStringParser.parseAndValidate(enrichmentTag.getValue()); } catch (JsonParseException e) { throw new IllegalArgumentException(e); } MODEL_OBJECT modelObject = enrichmentTagValueConverter.convert(enrichmentTagValue); judgmentUpdater.addToJudgment(judgment, modelObject); }
DefaultEnrichmentTagApplier implements EnrichmentTagApplier { @Override public void applyEnrichmentTag(Judgment judgment, EnrichmentTag enrichmentTag) { Preconditions.checkNotNull(judgment); Preconditions.checkNotNull(enrichmentTag); Preconditions.checkArgument(handlesEnrichmentTagType(enrichmentTag.getTagType())); TAG_VALUE enrichmentTagValue; try { enrichmentTagValue = jsonStringParser.parseAndValidate(enrichmentTag.getValue()); } catch (JsonParseException e) { throw new IllegalArgumentException(e); } MODEL_OBJECT modelObject = enrichmentTagValueConverter.convert(enrichmentTagValue); judgmentUpdater.addToJudgment(judgment, modelObject); } }
DefaultEnrichmentTagApplier implements EnrichmentTagApplier { @Override public void applyEnrichmentTag(Judgment judgment, EnrichmentTag enrichmentTag) { Preconditions.checkNotNull(judgment); Preconditions.checkNotNull(enrichmentTag); Preconditions.checkArgument(handlesEnrichmentTagType(enrichmentTag.getTagType())); TAG_VALUE enrichmentTagValue; try { enrichmentTagValue = jsonStringParser.parseAndValidate(enrichmentTag.getValue()); } catch (JsonParseException e) { throw new IllegalArgumentException(e); } MODEL_OBJECT modelObject = enrichmentTagValueConverter.convert(enrichmentTagValue); judgmentUpdater.addToJudgment(judgment, modelObject); } DefaultEnrichmentTagApplier(String handledEnrichmentTagType); }
DefaultEnrichmentTagApplier implements EnrichmentTagApplier { @Override public void applyEnrichmentTag(Judgment judgment, EnrichmentTag enrichmentTag) { Preconditions.checkNotNull(judgment); Preconditions.checkNotNull(enrichmentTag); Preconditions.checkArgument(handlesEnrichmentTagType(enrichmentTag.getTagType())); TAG_VALUE enrichmentTagValue; try { enrichmentTagValue = jsonStringParser.parseAndValidate(enrichmentTag.getValue()); } catch (JsonParseException e) { throw new IllegalArgumentException(e); } MODEL_OBJECT modelObject = enrichmentTagValueConverter.convert(enrichmentTagValue); judgmentUpdater.addToJudgment(judgment, modelObject); } DefaultEnrichmentTagApplier(String handledEnrichmentTagType); @Override void applyEnrichmentTag(Judgment judgment, EnrichmentTag enrichmentTag); @Override boolean handlesEnrichmentTagType(String enrichmentTagType); void setJsonStringParser(JsonStringParser<TAG_VALUE> jsonStringParser); void setEnrichmentTagValueConverter(EnrichmentTagValueConverter<TAG_VALUE, MODEL_OBJECT> enrichmentTagValueConverter); void setJudgmentUpdater(JudgmentUpdater<MODEL_OBJECT> judgmentUpdater); }
DefaultEnrichmentTagApplier implements EnrichmentTagApplier { @Override public void applyEnrichmentTag(Judgment judgment, EnrichmentTag enrichmentTag) { Preconditions.checkNotNull(judgment); Preconditions.checkNotNull(enrichmentTag); Preconditions.checkArgument(handlesEnrichmentTagType(enrichmentTag.getTagType())); TAG_VALUE enrichmentTagValue; try { enrichmentTagValue = jsonStringParser.parseAndValidate(enrichmentTag.getValue()); } catch (JsonParseException e) { throw new IllegalArgumentException(e); } MODEL_OBJECT modelObject = enrichmentTagValueConverter.convert(enrichmentTagValue); judgmentUpdater.addToJudgment(judgment, modelObject); } DefaultEnrichmentTagApplier(String handledEnrichmentTagType); @Override void applyEnrichmentTag(Judgment judgment, EnrichmentTag enrichmentTag); @Override boolean handlesEnrichmentTagType(String enrichmentTagType); void setJsonStringParser(JsonStringParser<TAG_VALUE> jsonStringParser); void setEnrichmentTagValueConverter(EnrichmentTagValueConverter<TAG_VALUE, MODEL_OBJECT> enrichmentTagValueConverter); void setJudgmentUpdater(JudgmentUpdater<MODEL_OBJECT> judgmentUpdater);  }