BP-787 add some tests
diff --git a/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/util/ReportGroupDtoConverter2.java b/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/util/ReportGroupDtoConverter2.java
index 0ab81b2..d59b94b 100644
--- a/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/util/ReportGroupDtoConverter2.java
+++ b/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/util/ReportGroupDtoConverter2.java
@@ -147,7 +147,7 @@
return reportGroupDto;
}
- private void addOneUserString(int i, List<StandbyScheduleBodySelectionDto> dayGroupList,
+ public void addOneUserString(int i, List<StandbyScheduleBodySelectionDto> dayGroupList,
ReportGroupDto reportGroupDto, ReportDto reportDto,
Map<Long, StandbyScheduleBodySelectionDto> lastBodyMap) {
diff --git a/oKBereitschaftsplanungBackend/src/test/java/org/eclipse/openk/sp/dto/UserSmallSelectionDtoTest.java b/oKBereitschaftsplanungBackend/src/test/java/org/eclipse/openk/sp/dto/UserSmallSelectionDtoTest.java
index a0a7343..2dd41bd 100644
--- a/oKBereitschaftsplanungBackend/src/test/java/org/eclipse/openk/sp/dto/UserSmallSelectionDtoTest.java
+++ b/oKBereitschaftsplanungBackend/src/test/java/org/eclipse/openk/sp/dto/UserSmallSelectionDtoTest.java
@@ -35,5 +35,12 @@
u.setLastname("LastName");
assertEquals("LastName", u.getLastname());
+ ContactDataDto contactData = new ContactDataDto();
+ u.setBusinessContactData(contactData);
+ assertEquals(contactData, u.getBusinessContactData());
+
+ u.setPrivateContactData(contactData);
+ assertEquals(contactData, u.getPrivateContactData());
+
}
}
diff --git a/oKBereitschaftsplanungBackend/src/test/java/org/eclipse/openk/sp/rest/reports/ReportRestServiceTest.java b/oKBereitschaftsplanungBackend/src/test/java/org/eclipse/openk/sp/rest/reports/ReportRestServiceTest.java
index 3a58279..d165583 100644
--- a/oKBereitschaftsplanungBackend/src/test/java/org/eclipse/openk/sp/rest/reports/ReportRestServiceTest.java
+++ b/oKBereitschaftsplanungBackend/src/test/java/org/eclipse/openk/sp/rest/reports/ReportRestServiceTest.java
@@ -14,6 +14,7 @@
import org.eclipse.openk.sp.db.dao.StandbyListRepository;
import org.eclipse.openk.sp.db.model.StandbyGroup;
import org.eclipse.openk.sp.db.model.StandbyList;
+import org.eclipse.openk.sp.dto.report.ReportDto;
import org.eclipse.openk.sp.exceptions.SpException;
import org.eclipse.openk.sp.util.DateHelper;
import org.junit.Test;
@@ -78,5 +79,54 @@
response, jwt);
assertNotNull(result);
+ Mockito.when(reportController.generateReport(Mockito.any())).thenThrow(new SpException());
+
+ // If group is input parameter
+ result = reportRestService.generateReport("Autoplan", null, 1L, null, "pdf", date1, date2, "Plan-Ebene",
+ response, jwt);
+ assertNotNull(result);
+
+ }
+
+ @Test
+ public void generateReportNewTest() throws SpException, IOException {
+ String jwt = "LET-ME-IN";
+ Response result;
+
+ HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
+ StandbyGroup standbyGroup = new StandbyGroup();
+ standbyGroup.setId(1L);
+ standbyGroup.setTitle("Einsatzgruppe1");
+
+ StandbyList standbyList = new StandbyList();
+ standbyList.setId(1L);
+ standbyList.setTitle("Einsatzliste1");
+ standbyList.getLsStandbyGroups().add(standbyGroup);
+
+ File mockFile = new ClassPathResource("reports/Autoplan.pdf").getFile();
+ Mockito.when(standbyListRepository.findOne(Mockito.any())).thenReturn(standbyList);
+ Mockito.when(standbyGroupRepository.findOne(Mockito.any())).thenReturn(standbyGroup);
+ Mockito.when(reportController.generateReport(Mockito.any())).thenReturn(mockFile);
+
+ Date date1 = DateHelper.getDate(2018, 10, 11, 12, 00, 00);
+ Date date2 = DateHelper.getDate(2018, 10, 11, 12, 00, 00);
+
+ ReportDto reportDto = new ReportDto();
+ reportDto.setValidFrom(date1);
+ reportDto.setValidTo(date2);
+
+ reportDto.setStandByList(standbyList);
+ reportDto.setStatusId(1L);
+
+ // If list is input parameter
+ result = reportRestService.generateReportNew(response, jwt, reportDto);
+ assertNotNull(result);
+
+ Mockito.when(reportController.generateReport(Mockito.any())).thenThrow(new SpException());
+
+ // If group is input parameter
+ result = reportRestService.generateReportNew(response, jwt, null);
+ assertNotNull(result);
+
}
}
diff --git a/oKBereitschaftsplanungBackend/src/test/java/org/eclipse/openk/sp/util/ReportGroupDtoConverterTest2.java b/oKBereitschaftsplanungBackend/src/test/java/org/eclipse/openk/sp/util/ReportGroupDtoConverterTest2.java
index 0048486..fdaf708 100644
--- a/oKBereitschaftsplanungBackend/src/test/java/org/eclipse/openk/sp/util/ReportGroupDtoConverterTest2.java
+++ b/oKBereitschaftsplanungBackend/src/test/java/org/eclipse/openk/sp/util/ReportGroupDtoConverterTest2.java
@@ -32,10 +32,12 @@
import org.eclipse.openk.sp.dto.StandbyScheduleBodySelectionDto;
import org.eclipse.openk.sp.dto.StandbyScheduleDto;
import org.eclipse.openk.sp.dto.UserSmallSelectionDto;
+import org.eclipse.openk.sp.dto.planning.PlanRowsDto;
import org.eclipse.openk.sp.dto.report.ReportDto;
import org.eclipse.openk.sp.dto.report.ReportGroupDto;
import org.eclipse.openk.sp.dto.report.ReportInputDto;
import org.eclipse.openk.sp.exceptions.SpException;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@@ -250,4 +252,24 @@
reportGroupDtoConverter.checkEmpty(dayGroupList, groupId);
}
+
+ @Ignore
+ @Test
+ public void addOneUserString() throws SpException {
+
+ FileHelperTest fh = new FileHelperTest();
+ String json = fh.loadStringFromResource("testStandbyScheduleDto.json");
+ StandbyScheduleDto plan = (StandbyScheduleDto) new Gson().fromJson(json, StandbyScheduleDto.class);
+ PlanRowsDto row = plan.getRow(DateHelper.getDate(2019, 02, 10));
+ List<StandbyScheduleBodySelectionDto> dayGroupList = row.getGroupList(3L);
+
+ int i = 1;
+ ReportGroupDto reportGroupDto = new ReportGroupDto();
+ ReportDto reportDto = new ReportDto();
+ reportDto.setReportName("test");
+ Map<Long, StandbyScheduleBodySelectionDto> lastBodyMap = new HashMap<>();
+
+ reportGroupDtoConverter.addOneUserString(i, dayGroupList, reportGroupDto, reportDto, lastBodyMap);
+
+ }
}