@Test public void applyEnrichmentTag_JsonParseEx() throws Exception { when(jsonStringParser.parseAndValidate(Mockito.anyString())).thenThrow(new IllegalArgumentException()); catchException(defaultEnrichmentTagApplier).applyEnrichmentTag(judgment, enrichmentTag); assertTrue(caughtException() instanceof IllegalArgumentException); verify(jsonStringParser).parseAndValidate(enrichmentTag.getValue()); verifyZeroInteractions(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);  }