### Question:
RegisterLocationController { @PostMapping(value = ENDPOINT) public ResponseEntity registerLocation(@RequestBody Location location) { ResponseEntity responseEntity; final HttpResponse httpResponse = adapter.registerLocation(location); switch (httpResponse.getStatus()) { case CREATED: responseEntity = ResponseEntity .created(URI.create(ENDPOINT + "/" + location.getName())).body(location); break; case CONFLICT: responseEntity = ResponseEntity.status(HttpStatus.CONFLICT).build(); break; case BAD_REQUEST: responseEntity = ResponseEntity.badRequest().body(httpResponse); break; default: responseEntity = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(httpResponse); } return responseEntity; } RegisterLocationController(final RegisterLocationInputPort inputPort); @PostMapping(value = ENDPOINT) ResponseEntity registerLocation(@RequestBody Location location);  }### Answer:
@Test void test_registerLocation_noLocation_doesNotRegister() { final RegisterLocationController controller = new RegisterLocationController( new MockRegisterLocationInputPort()); final Location location = new Location(); location.setName("SBZ"); location.setAddress("Sibiu Airport"); final ResponseEntity<?> responseEntity = controller.registerLocation(null); Assertions.assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode()); }
@Test void test_registerLocation_noLocationName_doesNotRegister() { final RegisterLocationController controller = new RegisterLocationController( new MockRegisterLocationInputPort()); final Location location = new Location(); location.setAddress("Sibiu Airport"); final ResponseEntity<?> responseEntity = controller.registerLocation(location); Assertions.assertEquals(HttpStatus.BAD_REQUEST, responseEntity.getStatusCode()); }
@Test void test_registerLocation_validLocation_registers() { final RegisterLocationController controller = new RegisterLocationController( new MockRegisterLocationInputPort()); final Location location = new Location(); location.setName("SBZ"); location.setAddress("Sibiu Airport"); final ResponseEntity<?> responseEntity = controller.registerLocation(location); Assertions.assertEquals(ResponseEntity .created(URI.create(RegisterLocationController.ENDPOINT + "/" + location.getName())) .body(location), responseEntity); }
@Test void test_registerLocation_duplicateRenter_doesNotRegister() { final RegisterLocationController controller = new RegisterLocationController( new MockRegisterLocationInputPort()); final Location location = new Location(); location.setName("SBZ"); location.setAddress("Sibiu Airport"); controller.registerLocation(location); ResponseEntity<?> responseEntity = controller.registerLocation(location); Assertions.assertEquals(ResponseEntity.status(HttpStatus.CONFLICT).build(), responseEntity); }