@Test void writeEntityTypesTest() { EntityType entityType1 = mock(EntityType.class); EntityType entityType2 = mock(EntityType.class); EntityType entityType3 = mock(EntityType.class); EntityType entityType4 = mock(EntityType.class); when(entityType1.isAbstract()).thenReturn(false); when(entityType2.isAbstract()).thenReturn(false); when(entityType3.isAbstract()).thenReturn(true); when(entityType4.isAbstract()).thenReturn(false); when(entityType3.getId()).thenReturn("3"); LinkedList<EntityType> entityTypes = new LinkedList<>(); entityTypes.add(entityType1); entityTypes.add(entityType2); entityTypes.add(entityType3); entityTypes.add(entityType4); XlsxWriter xlsxWriter = mock(XlsxWriter.class); service.writeEntityTypes(entityTypes, xlsxWriter); ArgumentCaptor<Stream> argumentCaptor = ArgumentCaptor.forClass(Stream.class); verify(xlsxWriter).writeRows(argumentCaptor.capture(), eq(EMX_ENTITIES)); Stream<List> argument = argumentCaptor.getValue(); List<Object> actual = argument.collect(Collectors.toList()).get(0); assertEquals("3", actual.get(0)); }
void writeEntityTypes(Collection<EntityType> entityTypes, XlsxWriter writer) { LinkedList<EntityType> sortedEntityTypes = sortEntityTypesAbstractFirst(entityTypes); if (!writer.hasSheet(EMX_ENTITIES)) { writer.createSheet(EMX_ENTITIES, newArrayList(ENTITIES_ATTRS.keySet())); } writer.writeRows(sortedEntityTypes.stream().map(EntityTypeMapper::map), EMX_ENTITIES); }
EmxExportServiceImpl implements EmxExportService { void writeEntityTypes(Collection<EntityType> entityTypes, XlsxWriter writer) { LinkedList<EntityType> sortedEntityTypes = sortEntityTypesAbstractFirst(entityTypes); if (!writer.hasSheet(EMX_ENTITIES)) { writer.createSheet(EMX_ENTITIES, newArrayList(ENTITIES_ATTRS.keySet())); } writer.writeRows(sortedEntityTypes.stream().map(EntityTypeMapper::map), EMX_ENTITIES); } }
EmxExportServiceImpl implements EmxExportService { void writeEntityTypes(Collection<EntityType> entityTypes, XlsxWriter writer) { LinkedList<EntityType> sortedEntityTypes = sortEntityTypesAbstractFirst(entityTypes); if (!writer.hasSheet(EMX_ENTITIES)) { writer.createSheet(EMX_ENTITIES, newArrayList(ENTITIES_ATTRS.keySet())); } writer.writeRows(sortedEntityTypes.stream().map(EntityTypeMapper::map), EMX_ENTITIES); } EmxExportServiceImpl(DataService dataService, ContextMessageSource contextMessageSource); }
EmxExportServiceImpl implements EmxExportService { void writeEntityTypes(Collection<EntityType> entityTypes, XlsxWriter writer) { LinkedList<EntityType> sortedEntityTypes = sortEntityTypesAbstractFirst(entityTypes); if (!writer.hasSheet(EMX_ENTITIES)) { writer.createSheet(EMX_ENTITIES, newArrayList(ENTITIES_ATTRS.keySet())); } writer.writeRows(sortedEntityTypes.stream().map(EntityTypeMapper::map), EMX_ENTITIES); } EmxExportServiceImpl(DataService dataService, ContextMessageSource contextMessageSource); @Override @Transactional(readOnly = true, isolation = Isolation.SERIALIZABLE) void export(
      List<EntityType> entityTypes,
      List<Package> packages,
      Path downloadFilePath,
      Progress progress); }
EmxExportServiceImpl implements EmxExportService { void writeEntityTypes(Collection<EntityType> entityTypes, XlsxWriter writer) { LinkedList<EntityType> sortedEntityTypes = sortEntityTypesAbstractFirst(entityTypes); if (!writer.hasSheet(EMX_ENTITIES)) { writer.createSheet(EMX_ENTITIES, newArrayList(ENTITIES_ATTRS.keySet())); } writer.writeRows(sortedEntityTypes.stream().map(EntityTypeMapper::map), EMX_ENTITIES); } EmxExportServiceImpl(DataService dataService, ContextMessageSource contextMessageSource); @Override @Transactional(readOnly = true, isolation = Isolation.SERIALIZABLE) void export(
      List<EntityType> entityTypes,
      List<Package> packages,
      Path downloadFilePath,
      Progress progress);  }