@Test public void testWrite() { JsonFileWriter file = Mockito.mock(JsonFileWriter.class); ErrorFile errorFile = Mockito.mock(ErrorFile.class); Entity entity = Mockito.mock(Entity.class); Entity check = writer.write(entity, file, errorFile); Assert.assertEquals(treatedEntity, check); try { Mockito.verify(file, Mockito.times(1)).write(treatedEntity); } catch (IOException e) { Assert.fail(); } }
public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; }
EntityWriter { public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; } }
EntityWriter { public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; } EntityWriter(Treatment treatment); }
EntityWriter { public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; } EntityWriter(Treatment treatment); Entity write(Entity entity, JsonFileWriter file, ErrorFile errors); }
EntityWriter { public Entity write(Entity entity, JsonFileWriter file, ErrorFile errors) { Entity treated = applicator.apply(entity); try { file.write(treated); } catch (JsonProcessingException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } catch (IOException e) { LOG.error("Error while extracting from " + entity.getType(), e); errors.logEntityError(entity); } return treated; } EntityWriter(Treatment treatment); Entity write(Entity entity, JsonFileWriter file, ErrorFile errors);  }