FormatRegistrationService { public ExportFormat getByName(String formatName) { return types .stream() .filter(f -> equalsIgnoreCase(formatName, f.getName())) .findFirst() .orElse(null); } FormatRegistrationService(List<ExportFormat> types); Stream<ExportFormat> getExternalFormats(); ExportFormat getByName(String formatName);  }
@Test public void shouldGetFormatByItsName() { final ExportFormat csvFormat = service.getByName(CSVFormat.CSV); Assert.assertTrue(csvFormat instanceof CSVFormat); }
@Test public void shouldNotGetAnyFormat() { final ExportFormat noFormat = service.getByName("toto"); Assert.assertNull(noFormat); }