Commit 79e71b0c authored by Marco Descher's avatar Marco Descher 🏔

[16258] IAppointmentService#getTypes

parent 6133841b
Pipeline #12098 passed with stages
in 4 minutes and 55 seconds
......@@ -43,7 +43,6 @@ public class AppointmentService implements IAppointmentService {
private static final int STATE_EMPTY = 0; //leer
private static final int STATE_DEFAULT = 1; //standard
private List<String> types = null;
private List<String> states = null;
@Reference
......@@ -69,7 +68,7 @@ public class AppointmentService implements IAppointmentService {
@Activate
public void activate(){
//@TODO server support ?
types = iConfigService.getAsList(AG_TERMINTYPEN, null);
List<String> types = getTypes();
states = iConfigService.getAsList(AG_TERMINSTATUS, null);
if (types == null || types.size() < 3) {
types = Arrays.asList(Messages.Appointment_Range_Free,
......@@ -210,6 +209,7 @@ public class AppointmentService implements IAppointmentService {
@Override
public String getType(AppointmentType type){
List<String> types = getTypes();
if (type != null) {
switch (type) {
case BOOKED:
......@@ -244,9 +244,8 @@ public class AppointmentService implements IAppointmentService {
@Override
public void addType(String type){
String tt = StringTool.join(types, ",") + "," + type;
String tt = StringTool.join(getTypes(), ",") + "," + type;
iConfigService.set(AG_TERMINTYPEN, tt);
types = iConfigService.getAsList(AG_TERMINTYPEN, null);
}
@Override
......@@ -274,4 +273,9 @@ public class AppointmentService implements IAppointmentService {
});
return ret;
}
@Override
public List<String> getTypes(){
return new ArrayList<String>(iConfigService.getAsList(AG_TERMINTYPEN, null));
}
}
......@@ -74,4 +74,11 @@ public interface IAppointmentService {
* @return
*/
public List<Area> getAreas();
/**
* Get all configured type strings
*
* @return
*/
public List<String> getTypes();
}
......@@ -27,29 +27,36 @@ import ch.elexis.core.utils.OsgiServiceUtil;
public class IAppointmentServiceTest extends AbstractServiceTest {
private IAppointmentService appointmentService = OsgiServiceUtil.getService(IAppointmentService.class).get();
private IAppointmentService appointmentService =
OsgiServiceUtil.getService(IAppointmentService.class).get();
private IAppointment savedAppointment;
@BeforeClass
public static void beforeClass() {
public static void beforeClass(){
IConfigService iConfigService = OsgiServiceUtil.getService(IConfigService.class).get();
iConfigService.set("agenda/bereiche", "Notfall,MPA,OP,Arzt 1,Arzt 2");
iConfigService.set("agenda/bereich/Arzt 1/type", "CONTACT/be5370812884c8fc5019123");
iConfigService.set("agenda/TerminTypen",
"frei,gesperrt,Notfall,Selbstzahler,Neuer Pat,Kontrolle,Termin,Checkup,OP,24h-BD / ApneaLink,Medicosearch,Sperrung,Sitzung,Reminder,Sonografie");
}
@Before
public void before(){
savedAppointment = new IAppointmentBuilder(coreModelService, "Notfall", LocalDateTime.of(2018, 01, 02, 9, 0), LocalDateTime.of(2018, 01, 02, 9, 30),
appointmentService.getType(AppointmentType.BOOKED), appointmentService.getState(AppointmentState.DEFAULT)).buildAndSave();
public void before(){
savedAppointment = new IAppointmentBuilder(coreModelService, "Notfall",
LocalDateTime.of(2018, 01, 02, 9, 0), LocalDateTime.of(2018, 01, 02, 9, 30),
appointmentService.getType(AppointmentType.BOOKED),
appointmentService.getState(AppointmentState.DEFAULT)).buildAndSave();
}
@Test
public void testCommon() {
Optional<IAppointment> load = coreModelService.load(savedAppointment.getId(), IAppointment.class);
public void testCommon(){
Optional<IAppointment> load =
coreModelService.load(savedAppointment.getId(), IAppointment.class);
assertTrue(load.isPresent());
assertEquals(30, load.get().getDurationMinutes().intValue());
assertEquals(appointmentService.getType(AppointmentType.BOOKED), load.get().getType());
assertEquals(1, coreModelService.getQuery(IAppointment.class).execute().size());
assertEquals(1, coreModelService.getQuery(IAppointment.class).execute().size());
assertEquals(15, appointmentService.getTypes().size());
}
@Test
......@@ -63,14 +70,16 @@ public class IAppointmentServiceTest extends AbstractServiceTest {
List<IAppointment> results = query.execute();
// check boundaries sorted by start time
assertEquals(3, results.size());
results = results.stream().sorted((p1, p2) -> p1.getStartTime().compareTo(p2.getStartTime())).collect(Collectors.toList());
assertEquals(LocalDateTime.of(2018, 01, 02, 0, 0), results.get(0).getStartTime());
assertEquals(LocalDateTime.of(2018, 01, 02, 8, 0), results.get(0).getEndTime());
assertEquals(LocalDateTime.of(2018, 01, 02, 9, 0), results.get(1).getStartTime());
assertEquals(LocalDateTime.of(2018, 01, 02, 9, 30), results.get(1).getEndTime());
assertEquals(LocalDateTime.of(2018, 01, 02, 18, 0), results.get(2).getStartTime());
assertEquals(LocalDateTime.of(2018, 01, 02, 23, 59), results.get(2).getEndTime());
assertEquals(3, results.size());
results =
results.stream().sorted((p1, p2) -> p1.getStartTime().compareTo(p2.getStartTime()))
.collect(Collectors.toList());
assertEquals(LocalDateTime.of(2018, 01, 02, 0, 0), results.get(0).getStartTime());
assertEquals(LocalDateTime.of(2018, 01, 02, 8, 0), results.get(0).getEndTime());
assertEquals(LocalDateTime.of(2018, 01, 02, 9, 0), results.get(1).getStartTime());
assertEquals(LocalDateTime.of(2018, 01, 02, 9, 30), results.get(1).getEndTime());
assertEquals(LocalDateTime.of(2018, 01, 02, 18, 0), results.get(2).getStartTime());
assertEquals(LocalDateTime.of(2018, 01, 02, 23, 59), results.get(2).getEndTime());
}
@Test
......@@ -79,7 +88,7 @@ public class IAppointmentServiceTest extends AbstractServiceTest {
assertEquals(1, coreModelService.getQuery(IAppointment.class).execute().size());
appointmentService.updateBoundaries("Notfall", LocalDate.of(2018, 01, 02));
//@todo on server its always 3
assertEquals(1, coreModelService.getQuery(IAppointment.class).execute().size());
assertEquals(1, coreModelService.getQuery(IAppointment.class).execute().size());
}
@Test
......@@ -98,19 +107,19 @@ public class IAppointmentServiceTest extends AbstractServiceTest {
@Test
public void testDelete(){
// delete single
assertEquals(1, coreModelService.getQuery(IAppointment.class).execute().size());
assertEquals(1, coreModelService.getQuery(IAppointment.class).execute().size());
appointmentService.delete(savedAppointment, false);
assertEquals(0, coreModelService.getQuery(IAppointment.class).execute().size());
assertEquals(0, coreModelService.getQuery(IAppointment.class).execute().size());
//@todo delete with linkgroup
}
@Test
public void getAreas() {
public void getAreas(){
List<Area> areas = appointmentService.getAreas();
assertEquals(5, areas.size());
for (Area area : areas) {
if("Arzt 1".equals(area.getName())) {
if ("Arzt 1".equals(area.getName())) {
assertEquals(AreaType.CONTACT, area.getType());
assertEquals("be5370812884c8fc5019123", area.getContactId());
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment