Commision with grouos response
This commit is contained in:
@ -2,11 +2,16 @@ package com.plannaplan.responses.mappers;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.plannaplan.entities.Assignment;
|
||||
import com.plannaplan.entities.Commision;
|
||||
import com.plannaplan.entities.Groups;
|
||||
import com.plannaplan.responses.models.CommisionResponse;
|
||||
import com.plannaplan.responses.models.CommisionWithGroupsResponse;
|
||||
import com.plannaplan.types.WeekDay;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@ -20,4 +25,33 @@ public class CommisionResponseMappersTest {
|
||||
assertTrue(resposne.get(0).getCommisionDate().equals(coms.get(0).getCommisionDate().toString()));
|
||||
assertTrue(resposne.get(1).getCommisionDate().equals(coms.get(1).getCommisionDate().toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldMapListWithEntityToListOfResponsesWithGroups()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
|
||||
final Field reader = Commision.class.getDeclaredField("assignments");
|
||||
final Field groupReader = Groups.class.getDeclaredField("id");
|
||||
reader.setAccessible(true);
|
||||
groupReader.setAccessible(true);
|
||||
|
||||
final Commision com1 = new Commision(null);
|
||||
final Groups group1 = new Groups(43, "BRAK", null, 840, WeekDay.MONDAY, null);
|
||||
|
||||
groupReader.set(group1, Long.valueOf(8));
|
||||
reader.set(com1, Arrays.asList(new Assignment(group1, com1)));
|
||||
|
||||
final Commision com2 = new Commision(null);
|
||||
final Groups group2 = new Groups(124, "BRAK", null, 900, WeekDay.WEDNESDAY, null);
|
||||
|
||||
groupReader.set(group2, Long.valueOf(9));
|
||||
reader.set(com2, Arrays.asList(new Assignment(group2, com2)));
|
||||
|
||||
final List<CommisionWithGroupsResponse> resposne = CommisionResponseMappers
|
||||
.mapToResponseWithGroups(Arrays.asList(com1, com2));
|
||||
|
||||
assertTrue(resposne.size() == 2);
|
||||
assertTrue(resposne.get(0).getGroups().get(0) == 8);
|
||||
assertTrue(resposne.get(1).getGroups().get(0) == 9);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
package com.plannaplan.responses.models;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.plannaplan.entities.Assignment;
|
||||
import com.plannaplan.entities.Commision;
|
||||
import com.plannaplan.entities.Groups;
|
||||
import com.plannaplan.types.WeekDay;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class CommisionWithGroupsResponseTest {
|
||||
@Test
|
||||
public void shouldMapCommisionToResponse()
|
||||
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
|
||||
final Field reader = Commision.class.getDeclaredField("assignments");
|
||||
final Field groupReader = Groups.class.getDeclaredField("id");
|
||||
reader.setAccessible(true);
|
||||
groupReader.setAccessible(true);
|
||||
|
||||
final Commision com = new Commision(null);
|
||||
final Groups group = new Groups(43, "BRAK", null, 840, WeekDay.MONDAY, null);
|
||||
|
||||
groupReader.set(group, Long.valueOf(8));
|
||||
reader.set(com, Arrays.asList(new Assignment(group, com)));
|
||||
|
||||
final CommisionWithGroupsResponse comResponse = new CommisionWithGroupsResponse(com);
|
||||
|
||||
assertTrue(comResponse.getGroups().get(0) == 8);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user