### Question:
RegisterLocationUseCase implements RegisterLocationInputPort { @Override public void registerLocation(final RegisterLocationInputData inputData, final RegisterLocationOutputPort outputPort) { Location location = new Location(); location.setName(inputData.getName()); location.setAddress(inputData.getAddress()); boolean locationRegistered = false; final Optional<Location> locationOptional = gatewaysAccessor.getLocationGateway() .findByName(location.getName()); if (!locationOptional.isPresent()) { gatewaysAccessor.getLocationGateway().save(location); locationRegistered = true; } final RegisterLocationOutputData registerLocationOutputData = new RegisterLocationOutputData( locationRegistered); outputPort.present(registerLocationOutputData); } RegisterLocationUseCase(final GatewaysAccessor gatewaysAccessor); @Override void registerLocation(final RegisterLocationInputData inputData,
        final RegisterLocationOutputPort outputPort);  }### Answer:
@Test void test_registerLocation_registersLocation() { final RegisterLocationUseCase registerLocationUseCase = new RegisterLocationUseCase( gatewaysAccessor); RegisterLocationInputData registerLocationInputData = new RegisterLocationInputData( "SBZ Airport", "Şoseaua Alba Iulia nr. 73, Sibiu, România"); registerLocationUseCase .registerLocation(registerLocationInputData, registerLocationOutputData -> { Assertions.assertTrue(registerLocationOutputData.isLocationRegistered()); }); }
@Test void test_registerLocation_sameLocationIsRegisteredOnlyOnce() { final RegisterLocationUseCase registerLocationUseCase1 = new RegisterLocationUseCase( gatewaysAccessor); RegisterLocationInputData registerLocationInputData = new RegisterLocationInputData( "SBZ Airport", "Şoseaua Alba Iulia nr. 73, Sibiu, România"); registerLocationUseCase1 .registerLocation(registerLocationInputData, registerLocationOutputData -> { Assertions.assertTrue(registerLocationOutputData.isLocationRegistered()); }); final RegisterLocationUseCase registerLocationUseCase2 = new RegisterLocationUseCase( gatewaysAccessor); registerLocationUseCase2 .registerLocation(registerLocationInputData, registerLocationOutputData -> { Assertions.assertFalse(registerLocationOutputData.isLocationRegistered()); }); }
@Test void test_registerLocation_twoDifferentLocationsAreBothRegistered() { final RegisterLocationUseCase registerLocationUseCase1 = new RegisterLocationUseCase( gatewaysAccessor); RegisterLocationInputData registerLocationInputData = new RegisterLocationInputData( "SBZ Airport", "Şoseaua Alba Iulia nr. 73, Sibiu, România"); registerLocationUseCase1 .registerLocation(registerLocationInputData, registerLocationOutputData -> { Assertions.assertTrue(registerLocationOutputData.isLocationRegistered()); }); final RegisterLocationUseCase registerLocationUseCase2 = new RegisterLocationUseCase( gatewaysAccessor); registerLocationInputData = new RegisterLocationInputData("OTP Airport", "Calea Bucureştilor 224E, Otopeni 075150"); registerLocationUseCase2 .registerLocation(registerLocationInputData, registerLocationOutputData -> { Assertions.assertTrue(registerLocationOutputData.isLocationRegistered()); }); }