@Test public void shouldReturnProcessorsForMandatoryFields() throws Exception { List<String> headers = new ArrayList<String>(); headers.add("mandatory string field"); headers.add("mandatoryIntField"); NotNull notNullForString = mock(NotNull.class); NotNull notNullForInt = mock(NotNull.class); whenNew(NotNull.class).withArguments(CsvCellProcessors.typeMappings.get("String")).thenReturn(notNullForString); whenNew(NotNull.class).withArguments(CsvCellProcessors.typeMappings.get("int")).thenReturn(notNullForInt); List<CellProcessor> cellProcessors = CsvCellProcessors.getProcessors(dummyImportableClass, headers); assertEquals(2, cellProcessors.size()); assertThat((NotNull) cellProcessors.get(0), is(notNullForString)); assertThat((NotNull) cellProcessors.get(1), is(notNullForInt)); }
public static List<CellProcessor> getProcessors(ModelClass modelClass, List<String> headers) { List<CellProcessor> processors = new ArrayList<>(); for (String header : headers) { org.openlmis.upload.model.Field field = modelClass.findImportFieldWithName(header); CellProcessor processor = null; if (field != null) { processor = chainTypeProcessor(field); } processors.add(processor); } return processors; }
CsvCellProcessors { public static List<CellProcessor> getProcessors(ModelClass modelClass, List<String> headers) { List<CellProcessor> processors = new ArrayList<>(); for (String header : headers) { org.openlmis.upload.model.Field field = modelClass.findImportFieldWithName(header); CellProcessor processor = null; if (field != null) { processor = chainTypeProcessor(field); } processors.add(processor); } return processors; } }
CsvCellProcessors { public static List<CellProcessor> getProcessors(ModelClass modelClass, List<String> headers) { List<CellProcessor> processors = new ArrayList<>(); for (String header : headers) { org.openlmis.upload.model.Field field = modelClass.findImportFieldWithName(header); CellProcessor processor = null; if (field != null) { processor = chainTypeProcessor(field); } processors.add(processor); } return processors; }  }
CsvCellProcessors { public static List<CellProcessor> getProcessors(ModelClass modelClass, List<String> headers) { List<CellProcessor> processors = new ArrayList<>(); for (String header : headers) { org.openlmis.upload.model.Field field = modelClass.findImportFieldWithName(header); CellProcessor processor = null; if (field != null) { processor = chainTypeProcessor(field); } processors.add(processor); } return processors; }  static List<CellProcessor> getProcessors(ModelClass modelClass, List<String> headers); }
CsvCellProcessors { public static List<CellProcessor> getProcessors(ModelClass modelClass, List<String> headers) { List<CellProcessor> processors = new ArrayList<>(); for (String header : headers) { org.openlmis.upload.model.Field field = modelClass.findImportFieldWithName(header); CellProcessor processor = null; if (field != null) { processor = chainTypeProcessor(field); } processors.add(processor); } return processors; }  static List<CellProcessor> getProcessors(ModelClass modelClass, List<String> headers); static Map<String, CellProcessor> typeMappings; }