@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()); }
@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()); }
@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()); }
@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()); }
@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()); }
@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()); }
@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()); }
@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()); }