### Question:
RegisterRenterUseCase implements RegisterRenterInputPort { @Override public void registerRenter(final RegisterRenterInputData inputData, final RegisterRenterOutputPort outputPort) { Renter renter = new Renter(); renter.setFirstName(inputData.getFirstName()); renter.setLastName(inputData.getLastName()); renter.setEmail(inputData.getEmail()); renter.setTelephoneNumber(inputData.getTelephoneNumber()); boolean renterRegistered = false; final Optional<Renter> optionalRenter = gatewaysAccessor.getRenterGateway() .findByEmail(renter.getEmail()); if (!optionalRenter.isPresent()) { gatewaysAccessor.getRenterGateway().save(renter); renterRegistered = true; } final RegisterRenterOutputData registerRenterOutputData = new RegisterRenterOutputData( renterRegistered); outputPort.present(registerRenterOutputData); } RegisterRenterUseCase(final GatewaysAccessor gatewaysAccessor); @Override void registerRenter(final RegisterRenterInputData inputData,
        final RegisterRenterOutputPort outputPort);  }### Answer:
@Test void test_registerRenter_registersRenter() { final RegisterRenterUseCase registerRenterUseCase = new RegisterRenterUseCase( gatewaysAccessor); RegisterRenterInputData registerRenterInputData = new RegisterRenterInputData("John", "Doe", "john.doe@example.com"); registerRenterUseCase.registerRenter(registerRenterInputData, registerRenterOutputData -> { Assertions.assertTrue(registerRenterOutputData.isRenterRegistered()); }); }
@Test void test_registerRenter_sameRenterIsRegisteredOnlyOnce() { final RegisterRenterUseCase registerRenterUseCase1 = new RegisterRenterUseCase( gatewaysAccessor); RegisterRenterInputData registerRenterInputData1 = new RegisterRenterInputData("John", "Doe", "john.doe@example.com"); registerRenterUseCase1 .registerRenter(registerRenterInputData1, registerRenterOutputData -> { Assertions.assertTrue(registerRenterOutputData.isRenterRegistered()); }); final RegisterRenterUseCase registerRenterUseCase2 = new RegisterRenterUseCase( gatewaysAccessor); RegisterRenterInputData registerRenterInputData2 = new RegisterRenterInputData("John", "Doe", "john.doe@example.com"); registerRenterUseCase2 .registerRenter(registerRenterInputData2, registerRenterOutputData -> { Assertions.assertFalse(registerRenterOutputData.isRenterRegistered()); }); }
@Test void test_registerRenter_twoDifferentRentersAreBothRegistered() { final RegisterRenterUseCase registerRenterUseCase1 = new RegisterRenterUseCase( gatewaysAccessor); RegisterRenterInputData registerRenterInputData = new RegisterRenterInputData("John", "Doe", "john.doe@example.com"); registerRenterUseCase1.registerRenter(registerRenterInputData, registerRenterOutputData -> { Assertions.assertTrue(registerRenterOutputData.isRenterRegistered()); }); final RegisterRenterUseCase registerRenterUseCase2 = new RegisterRenterUseCase( gatewaysAccessor); registerRenterInputData = new RegisterRenterInputData("John", "Doe", "jane.doe@anotherexample.com"); registerRenterUseCase2.registerRenter(registerRenterInputData, registerRenterOutputData -> { Assertions.assertTrue(registerRenterOutputData.isRenterRegistered()); }); }