@Test public void convertValue_USE_FIRST_CONVERTER() { when(converter1.isApplicable(reportEntry.getType())).thenReturn(true); when(converter2.isApplicable(reportEntry.getType())).thenReturn(false); JsonElement json = mock(JsonElement.class); when(converter1.convertValue(reportEntry)).thenReturn(json); JsonElement retJson = converterManager.convertValue(reportEntry); assertTrue(retJson == json); }
public JsonElement convertValue(ReportEntry reportEntry) { for (ReportValueJsonConverter converter : converters) { if (converter.isApplicable(reportEntry.getType())) { return converter.convertValue(reportEntry); } } throw new IllegalArgumentException("No suitable converter of report entry with type " + reportEntry.getType()); }
ReportValueJsonConverterManager { public JsonElement convertValue(ReportEntry reportEntry) { for (ReportValueJsonConverter converter : converters) { if (converter.isApplicable(reportEntry.getType())) { return converter.convertValue(reportEntry); } } throw new IllegalArgumentException("No suitable converter of report entry with type " + reportEntry.getType()); } }
ReportValueJsonConverterManager { public JsonElement convertValue(ReportEntry reportEntry) { for (ReportValueJsonConverter converter : converters) { if (converter.isApplicable(reportEntry.getType())) { return converter.convertValue(reportEntry); } } throw new IllegalArgumentException("No suitable converter of report entry with type " + reportEntry.getType()); }  }
ReportValueJsonConverterManager { public JsonElement convertValue(ReportEntry reportEntry) { for (ReportValueJsonConverter converter : converters) { if (converter.isApplicable(reportEntry.getType())) { return converter.convertValue(reportEntry); } } throw new IllegalArgumentException("No suitable converter of report entry with type " + reportEntry.getType()); }  JsonElement convertValue(ReportEntry reportEntry); void setConverters(List<ReportValueJsonConverter> converters); }
ReportValueJsonConverterManager { public JsonElement convertValue(ReportEntry reportEntry) { for (ReportValueJsonConverter converter : converters) { if (converter.isApplicable(reportEntry.getType())) { return converter.convertValue(reportEntry); } } throw new IllegalArgumentException("No suitable converter of report entry with type " + reportEntry.getType()); }  JsonElement convertValue(ReportEntry reportEntry); void setConverters(List<ReportValueJsonConverter> converters);  }