Part3 has been ended. Renamed the test files. The test had status successed.

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2020-11-09 16:47:12 +01:00
parent 035de011f2
commit 7c7045c0e1
Signed by: y0rune
GPG Key ID: F204C385F57EB348
13 changed files with 75 additions and 71 deletions

View File

@ -40,6 +40,10 @@ Na koniec w przęglądarce dostaniesz w odpowiedzi token. W samym pliku można z
Żeby zobaczyć dokumentację api trzeba wejść w przeglądarce na `http://localhost:1285/swagger-ui.html` po odpaleniu aplikacji.
### Nazewnictwo odpowiedzi
Każdą odp zaczynamy od modelu, który opisuje np. `Courses` a kończymy na `Response`. Między tymi dwoma członami możemy dodawać modyfikatory opisujące dokładniej odpowiedź np. `Default`. W ten sposób możemy otrzymać nazwę `CoursesDefaultResponse.java`
## Packaging
Zeby spakowac apke do `jara` wystarcza dwie komendy zaczynajac z glownego katalogu projektu

View File

@ -9,7 +9,7 @@ import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Commision;
import com.plannaplan.entities.Course;
import com.plannaplan.entities.Groups;
import com.plannaplan.responses.models.GetCurrentAssignmentsResponse;
import com.plannaplan.responses.models.AssignmentResponse;
import com.plannaplan.entities.Lecturer;
import com.plannaplan.types.WeekDay;
@ -25,9 +25,9 @@ public class AssignmentResponseMappersTest {
new Lecturer("krul.", "Wladyslaw", "Potocki")), com),
new Assignment(new Groups(32, "A4-1", course, 420, WeekDay.MONDAY,
new Lecturer("krul.", "Wladyslaw", "Potocki")), com));
final List<GetCurrentAssignmentsResponse> response = AssignmentResponseMappers.mapToResponse(groups);
final List<AssignmentResponse> response = AssignmentResponseMappers.mapToResponse(groups);
assertTrue(response.size() == 1);
assertTrue(response.get(0) instanceof GetCurrentAssignmentsResponse);
assertTrue(response.get(0) instanceof AssignmentResponse);
}
}

View File

@ -6,8 +6,8 @@ import java.util.Arrays;
import java.util.List;
import com.plannaplan.entities.Course;
import com.plannaplan.responses.models.GetCoursesResponse;
import com.plannaplan.responses.models.GetCoursesWithGroupsResponse;
import com.plannaplan.responses.models.CoursesDefaultResponse;
import com.plannaplan.responses.models.CoursesWithGroupsResponse;
import org.junit.Test;
@ -15,21 +15,21 @@ public class CoursesResponseMappersTest {
@Test
public void shouldMapListCoursesToResponseList() {
final List<Course> courses = Arrays.asList(new Course(), new Course());
final List<GetCoursesResponse> response = CoursesResponseMappers.mapToGetCoursesResponse(courses);
final List<CoursesDefaultResponse> response = CoursesResponseMappers.mapToGetCoursesResponse(courses);
assertTrue(response.size() == 2);
assertTrue(response.get(0) instanceof GetCoursesResponse);
assertTrue(response.get(0) instanceof CoursesDefaultResponse);
}
@Test
public void shouldMapListCoursesToResponseWithGroupsList() {
final List<Course> courses = Arrays.asList(new Course(), new Course());
final List<GetCoursesWithGroupsResponse> response = CoursesResponseMappers
final List<CoursesWithGroupsResponse> response = CoursesResponseMappers
.mapToGetCoursesWithGroupsResponse(courses);
assertTrue(response.size() == 2);
assertTrue(response.get(0) instanceof GetCoursesWithGroupsResponse);
assertTrue(response.get(0) instanceof CoursesWithGroupsResponse);
}
}

View File

@ -7,9 +7,9 @@ import java.util.List;
import com.plannaplan.entities.Groups;
import com.plannaplan.entities.Lecturer;
import com.plannaplan.responses.models.DefaultGroupResponse;
import com.plannaplan.responses.models.GetCourseGroupsResponse;
import com.plannaplan.responses.models.WithCapacityGroupResponse;
import com.plannaplan.responses.models.GroupDefaultResponse;
import com.plannaplan.responses.models.CourseWithGroupsResponse;
import com.plannaplan.responses.models.GroupWithCapacityResponse;
import com.plannaplan.types.WeekDay;
import org.junit.Test;
@ -19,10 +19,10 @@ public class GroupsMappersTest {
public void shouldMapToResponseIncludingCapacity() {
final List<Groups> gropus = Arrays.asList(
new Groups(42, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")));
final List<WithCapacityGroupResponse> response = GroupsMappers.mapToCapacityResponse(gropus);
final List<GroupWithCapacityResponse> response = GroupsMappers.mapToCapacityResponse(gropus);
assert (response.get(0).getCapacity() == 42);
assert (response.get(0) instanceof WithCapacityGroupResponse);
assert (response.get(0) instanceof GroupWithCapacityResponse);
assert (response.size() == 1);
}
@ -30,9 +30,9 @@ public class GroupsMappersTest {
public void shouldMapToResponseWiothoutCapacity() {
final List<Groups> gropus = Arrays.asList(
new Groups(42, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")));
final List<DefaultGroupResponse> response = GroupsMappers.mapToDefaultResponse(gropus);
final List<GroupDefaultResponse> response = GroupsMappers.mapToDefaultResponse(gropus);
assert (response.get(0) instanceof DefaultGroupResponse);
assert (response.get(0) instanceof GroupDefaultResponse);
assert (response.size() == 1);
}
@ -41,7 +41,7 @@ public class GroupsMappersTest {
final List<Groups> groups = Arrays.asList(
new Groups(150, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")), new Groups(24, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")));
final GetCourseGroupsResponse<DefaultGroupResponse> response = GroupsMappers.mapToGetCourseGroupsDefaultResponse(groups);
final CourseWithGroupsResponse<GroupDefaultResponse> response = GroupsMappers.mapToGetCourseGroupsDefaultResponse(groups);
assertTrue(response.getClasses().size() == 1);
assertTrue(response.getLectures().size() == 1);

View File

@ -7,7 +7,7 @@ import java.util.List;
import com.plannaplan.entities.User;
import com.plannaplan.types.UserRoles;
import com.plannaplan.responses.models.SearchForStudentsResponse;
import com.plannaplan.responses.models.UserResponse;
import org.junit.Test;
@ -25,8 +25,8 @@ public class UserResponseMappersTest {
final List<User> users = Arrays.asList(new User(F_NAME, F_SURNAMENAME, F_EMAIL, UserRoles.TEST_USER),
new User(S_NAME, S_SURNAMENAME, S_EMAIL, UserRoles.TEST_USER));
final List<SearchForStudentsResponse> resposne = UserResponseMappers.mapToDefaultResponse(users);
final List<UserResponse> resposne = UserResponseMappers.mapToDefaultResponse(users);
assertTrue(resposne.size() == 2);
assertTrue(resposne.get(0) instanceof SearchForStudentsResponse);
assertTrue(resposne.get(0) instanceof UserResponse);
}
}

View File

@ -9,7 +9,7 @@ import com.plannaplan.types.WeekDay;
import org.junit.Test;
public class GetCurrentAssignmentsResponseTest {
public class AssignmentResponseTest {
@Test
public void shouldMapGroupsToResponse() {
@ -19,10 +19,10 @@ public class GetCurrentAssignmentsResponseTest {
final Groups classes = new Groups(22, "A4-2", null, 580, WeekDay.MONDAY,
new Lecturer("krul.", "Wladyslaw", "Potocki"));
final GetCurrentAssignmentsResponse response = new GetCurrentAssignmentsResponse(course, lecture, classes);
final AssignmentResponse response = new AssignmentResponse(course, lecture, classes);
assertTrue(response.getName() == "Kurs");
assertTrue(response.getLecture() instanceof WithCapacityGroupResponse);
assertTrue(response.getClasses() instanceof WithCapacityGroupResponse);
assertTrue(response.getLecture() instanceof GroupWithCapacityResponse);
assertTrue(response.getClasses() instanceof GroupWithCapacityResponse);
}
@Test
@ -31,9 +31,9 @@ public class GetCurrentAssignmentsResponseTest {
final Groups lecture = new Groups(142, "A4-1", null, 520, WeekDay.MONDAY,
new Lecturer("krul.", "Wladyslaw", "Potocki"));
final GetCurrentAssignmentsResponse response = new GetCurrentAssignmentsResponse(course, lecture);
final AssignmentResponse response = new AssignmentResponse(course, lecture);
assertTrue(response.getName() == "Kurs");
assertTrue(response.getLecture() instanceof WithCapacityGroupResponse);
assertTrue(response.getLecture() instanceof GroupWithCapacityResponse);
assertTrue(response.getClasses() == null);
}
@ -43,10 +43,10 @@ public class GetCurrentAssignmentsResponseTest {
final Groups classes = new Groups(22, "A4-2", null, 580, WeekDay.MONDAY,
new Lecturer("krul.", "Wladyslaw", "Potocki"));
final GetCurrentAssignmentsResponse response = new GetCurrentAssignmentsResponse(course, classes);
final AssignmentResponse response = new AssignmentResponse(course, classes);
assertTrue(response.getName() == "Kurs");
assertTrue(response.getLecture() == null);
assertTrue(response.getClasses() instanceof WithCapacityGroupResponse);
assertTrue(response.getClasses() instanceof GroupWithCapacityResponse);
}
}

View File

@ -0,0 +1,28 @@
package com.plannaplan.responses.models;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.List;
import com.plannaplan.entities.Groups;
import org.junit.Test;
public class CourseWithGroupsResponseTest {
@Test public void shouldCreateInstance(){
final List<GroupDefaultResponse> classes = Arrays.asList(new GroupDefaultResponse(new Groups()));
final List<GroupDefaultResponse> lectures = Arrays.asList(new GroupDefaultResponse(new Groups()));
final CourseWithGroupsResponse<GroupDefaultResponse> instance = new CourseWithGroupsResponse<>(classes,lectures);
assertTrue(instance.getClasses().get(0) instanceof GroupDefaultResponse);
assertTrue(instance.getLectures().get(0) instanceof GroupDefaultResponse);
}
}

View File

@ -6,11 +6,11 @@ import com.plannaplan.entities.Course;
import org.junit.Test;
public class GetCoursesResponseTest {
public class CoursesDefaultResponseTest {
@Test
public void shouldMapFilledCourse() {
final Course course = new Course("Test", "XD");
final GetCoursesResponse response = new GetCoursesResponse(course);
final CoursesDefaultResponse response = new CoursesDefaultResponse(course);
assertTrue(response.getId() == null);
assertTrue(response.getName().equals("Test"));
@ -19,7 +19,7 @@ public class GetCoursesResponseTest {
@Test
public void shouldMapEmptyCourse() {
final Course course = new Course();
final GetCoursesResponse response = new GetCoursesResponse(course);
final CoursesDefaultResponse response = new CoursesDefaultResponse(course);
assertTrue(response.getId() == null);
assertTrue(response.getName().equals(""));

View File

@ -6,11 +6,11 @@ import com.plannaplan.entities.Course;
import org.junit.Test;
public class GetCoursesWithGroupsResponseTest {
public class CoursesWithGroupsResponseTest {
@Test
public void shouldMapCourseToResponseWithGroupsIncluded() {
final GetCoursesWithGroupsResponse response = new GetCoursesWithGroupsResponse(
final CoursesWithGroupsResponse response = new CoursesWithGroupsResponse(
new Course("Programowanie funkcyjne", "xd"));
assertTrue(response.getName() == "Programowanie funkcyjne");

View File

@ -1,28 +0,0 @@
package com.plannaplan.responses.models;
import static org.junit.Assert.assertTrue;
import java.util.Arrays;
import java.util.List;
import com.plannaplan.entities.Groups;
import org.junit.Test;
public class GetCourseGroupsResponseTest {
@Test public void shouldCreateInstance(){
final List<DefaultGroupResponse> classes = Arrays.asList(new DefaultGroupResponse(new Groups()));
final List<DefaultGroupResponse> lectures = Arrays.asList(new DefaultGroupResponse(new Groups()));
final GetCourseGroupsResponse<DefaultGroupResponse> instance = new GetCourseGroupsResponse<>(classes,lectures);
assertTrue(instance.getClasses().get(0) instanceof DefaultGroupResponse);
assertTrue(instance.getLectures().get(0) instanceof DefaultGroupResponse);
}
}

View File

@ -10,13 +10,13 @@ import com.plannaplan.types.WeekDay;
import org.junit.Test;
public class DefaultGroupResponseTest {
public class GroupDefaultResponseTest {
@Test
public void shouldMapAssignmentClassToResponse() {
final Assignment assignment = new Assignment(
new Groups(42, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")), null);
final DefaultGroupResponse response = new DefaultGroupResponse(assignment);
final GroupDefaultResponse response = new GroupDefaultResponse(assignment);
assertTrue(response.getDay() == 0);
assertTrue(response.getLecturer().equals("krul. Wladyslaw Potocki"));
assertTrue(response.getRoom().equals("A4-1"));
@ -29,7 +29,7 @@ public class DefaultGroupResponseTest {
final Groups group = new Groups(42, "A4-1", null, 520, WeekDay.MONDAY,
new Lecturer("krul.", "Wladyslaw", "Potocki"));
final DefaultGroupResponse response = new DefaultGroupResponse(group);
final GroupDefaultResponse response = new GroupDefaultResponse(group);
assertTrue(response.getDay() == 0);
assertTrue(response.getLecturer().equals("krul. Wladyslaw Potocki"));
assertTrue(response.getRoom().equals("A4-1"));
@ -41,7 +41,7 @@ public class DefaultGroupResponseTest {
public void shouldMapEmptyGroupClassToResponse() {
final Groups group = new Groups();
final DefaultGroupResponse response = new DefaultGroupResponse(group);
final GroupDefaultResponse response = new GroupDefaultResponse(group);
assertTrue(response.getDay() == -1);
assertTrue(response.getLecturer().equals(""));
assertTrue(response.getRoom().equals(""));

View File

@ -10,13 +10,13 @@ import com.plannaplan.types.WeekDay;
import org.junit.Test;
public class WithCapacityGroupResponseTest {
public class GroupWithCapacityResponseTest {
@Test
public void shouldMapAssignmentClassToResponse() {
final Assignment assignment = new Assignment(
new Groups(42, "A4-1", null, 520, WeekDay.MONDAY, new Lecturer("krul.", "Wladyslaw", "Potocki")), null);
final WithCapacityGroupResponse response = new WithCapacityGroupResponse(assignment);
final GroupWithCapacityResponse response = new GroupWithCapacityResponse(assignment);
assertTrue(response.getCapacity() == 42);
assertTrue(response.getDay() == 0);
assertTrue(response.getLecturer().equals("krul. Wladyslaw Potocki"));
@ -30,7 +30,7 @@ public class WithCapacityGroupResponseTest {
final Groups group = new Groups(42, "A4-1", null, 520, WeekDay.MONDAY,
new Lecturer("krul.", "Wladyslaw", "Potocki"));
final WithCapacityGroupResponse response = new WithCapacityGroupResponse(group);
final GroupWithCapacityResponse response = new GroupWithCapacityResponse(group);
assertTrue(response.getCapacity() == 42);
assertTrue(response.getDay() == 0);
assertTrue(response.getLecturer().equals("krul. Wladyslaw Potocki"));
@ -43,7 +43,7 @@ public class WithCapacityGroupResponseTest {
public void shouldMapEmptyGroupClassToResponse() {
final Groups group = new Groups();
final WithCapacityGroupResponse response = new WithCapacityGroupResponse(group);
final GroupWithCapacityResponse response = new GroupWithCapacityResponse(group);
assertTrue(response.getCapacity() == 0);
assertTrue(response.getDay() == -1);
assertTrue(response.getLecturer().equals(""));

View File

@ -7,14 +7,14 @@ import com.plannaplan.types.UserRoles;
import org.junit.Test;
public class SearchForStudentsResponseTest {
public class UserResponseTest {
private static final String NAME = "Tytus";
private static final String SURNAMENAME = "Romek";
private static final String EMAIL = "i@Atomek.pl";
@Test
public void shouldMapUserToResponseElement() {
final SearchForStudentsResponse response = new SearchForStudentsResponse(
final UserResponse response = new UserResponse(
new User(NAME, SURNAMENAME, EMAIL, UserRoles.TEST_USER));
assertTrue(response.getName().equals(NAME));
assertTrue(response.getSurname().equals(SURNAMENAME));