コード例 #1
0
 @Test
 public void test_createConferenceRoom_returns_BAD_REQUEST() {
   ConferenceRoom room = ConferenceRoomFixture.createConferenceRoom();
   doThrow(new ValidationException("")).when(conferenceRoomValidator).validate(room);
   ResponseEntity<String> response = controller.createConferenceRoom(room);
   assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
 }
コード例 #2
0
 @Test
 public void test_createConferenceRoom_returns_CREATED() {
   ConferenceRoom room = ConferenceRoomFixture.createConferenceRoom();
   ResponseEntity<String> response = controller.createConferenceRoom(room);
   assertEquals("Conference room created.", response.getBody());
   assertEquals(HttpStatus.CREATED, response.getStatusCode());
 }
コード例 #3
0
 @Test
 public void test_getAvailableConferenceRooms_returns_BAD_REQUEST() {
   doThrow(new ValidationException(""))
       .when(conferenceValidator)
       .validateDates(anyString(), anyString());
   ResponseEntity<ConferenceRooms> response =
       controller.getAvailableConferenceRooms("26/12/2015 12:00", "28/12/2015 12:00");
   assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
 }
コード例 #4
0
 @Test
 public void test_createConferenceRoom_returns_CONFLICT() {
   ConferenceRoom room = ConferenceRoomFixture.createConferenceRoom();
   doThrow(new ApplicationException("", ApplicationErrorCode.CONFLICT))
       .when(conferenceRoomService)
       .createConferenceRoom(any(com.conferenceplanner.core.domain.ConferenceRoom.class));
   ResponseEntity<String> response = controller.createConferenceRoom(room);
   assertEquals(HttpStatus.CONFLICT, response.getStatusCode());
 }
コード例 #5
0
 @Test
 public void test_getConferenceRoomAvailability_returns_NOT_FOUND() {
   doThrow(new ApplicationException("", ApplicationErrorCode.NOT_FOUND))
       .when(conferenceRoomService)
       .getConferenceRoomAvailabilityItems(anyInt());
   ResponseEntity<ConferenceRoomAvailability> response =
       controller.getConferenceRoomAvailability(1);
   assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
 }
コード例 #6
0
 @Test
 public void test_getAvailableConferenceRooms_returns_NOT_FOUND() {
   doThrow(new ApplicationException("", ApplicationErrorCode.NOT_FOUND))
       .when(conferenceRoomService)
       .getAvailableConferenceRooms(any(Conference.class));
   ResponseEntity<ConferenceRooms> response =
       controller.getAvailableConferenceRooms("26/12/2015 12:00", "28/12/2015 12:00");
   assertEquals(HttpStatus.NOT_FOUND, response.getStatusCode());
 }
コード例 #7
0
 @Test
 public void test_getAvailableConferenceRooms_returns_OK() {
   ConferenceInterval interval = mock(ConferenceInterval.class);
   when(conferenceValidator.validateDates(anyString(), anyString())).thenReturn(interval);
   List<ConferenceRoom> rooms = ConferenceRoomFixture.createConferenceRooms(2);
   when(conferenceRoomFactory.create(anyList())).thenReturn(rooms);
   ResponseEntity<ConferenceRooms> response =
       controller.getAvailableConferenceRooms("26/12/2015 12:00", "28/12/2015 12:00");
   assertEquals(rooms.size(), response.getBody().getConferenceRooms().size());
   assertEquals(HttpStatus.OK, response.getStatusCode());
 }
コード例 #8
0
 @Test
 public void test_getConferenceRoomAvailability_returns_OK() {
   ConferenceRoomAvailability conferenceRoomAvailability = mock(ConferenceRoomAvailability.class);
   when(conferenceRoomAvailabilityFactory.create(
           any(com.conferenceplanner.core.domain.ConferenceRoomAvailability.class)))
       .thenReturn(conferenceRoomAvailability);
   ResponseEntity<ConferenceRoomAvailability> response =
       controller.getConferenceRoomAvailability(1);
   assertEquals(conferenceRoomAvailability, response.getBody());
   assertEquals(HttpStatus.OK, response.getStatusCode());
 }