JPAConfiguration { public static RequireDriverName builder() { return driverName -> driverURL -> new ReadyToBuild(driverName, driverURL, NO_CREDENTIAL, NO_TEST_ON_BORROW, NO_VALIDATION_QUERY_TIMEOUT_SEC, NO_VALIDATION_QUERY); } @VisibleForTesting  JPAConfiguration(String driverName, String driverURL, Optional<Credential> credential, Optional<Boolean> testOnBorrow,
                     Optional<Integer> validationQueryTimeoutSec, Optional<String> validationQuery); static RequireDriverName builder(); String getDriverName(); String getDriverURL(); Optional<Boolean> isTestOnBorrow(); Optional<Integer> getValidationQueryTimeoutSec(); Optional<String> getValidationQuery(); Optional<Credential> getCredential();  }
@Test void buildShouldThrowWhenValidationQueryTimeoutSecIsZero() { assertThatThrownBy(() -> JPAConfiguration.builder() .driverName(DRIVER_NAME) .driverURL(DRIVER_URL) .validationQueryTimeoutSec(0) .build()) .isInstanceOf(IllegalArgumentException.class) .hasMessage("validationQueryTimeoutSec is required to be greater than 0"); }
@Test void buildShouldThrowWhenValidationQueryTimeoutSecIsNegative() { assertThatThrownBy(() -> JPAConfiguration.builder() .driverName(DRIVER_NAME) .driverURL(DRIVER_URL) .validationQueryTimeoutSec(-1) .build()) .isInstanceOf(IllegalArgumentException.class) .hasMessage("validationQueryTimeoutSec is required to be greater than 0"); }
@Test void buildShouldThrowWhenPasswordIsNull() { assertThatThrownBy(() -> JPAConfiguration.builder() .driverName(DRIVER_NAME) .driverURL(DRIVER_URL) .username(USER_NAME) .password(null) .build()) .isInstanceOf(IllegalArgumentException.class) .hasMessage("username and password for connecting to database can't be blank"); }
@Test void buildShouldThrowWhenPasswordIsEmpty() { assertThatThrownBy(() -> JPAConfiguration.builder() .driverName(DRIVER_NAME) .driverURL(DRIVER_URL) .username(USER_NAME) .password(EMPTY_STRING) .build()) .isInstanceOf(IllegalArgumentException.class) .hasMessage("username and password for connecting to database can't be blank"); }
@Test void buildShouldThrowWhenUsernameIsNull() { assertThatThrownBy(() -> JPAConfiguration.builder() .driverName(DRIVER_NAME) .driverURL(DRIVER_URL) .username(null) .password(PASSWORD) .build()) .isInstanceOf(IllegalArgumentException.class) .hasMessage("username and password for connecting to database can't be blank"); }
@Test void buildShouldThrowWhenUsernameIsEmpty() { assertThatThrownBy(() -> JPAConfiguration.builder() .driverName(DRIVER_NAME) .driverURL(DRIVER_URL) .username(EMPTY_STRING) .password(PASSWORD) .build()) .isInstanceOf(IllegalArgumentException.class) .hasMessage("username and password for connecting to database can't be blank"); }