@Test public void shouldNotStartWithInvalidConfiguration() throws Exception { // use an empty configuration which should be invalid because of the lack of DB connection details Configuration config = Configuration.create().build(); // we expect the engine will log at least one error, so preface it ... logger.info("Attempting to start the connector with an INVALID configuration, so MULTIPLE error messages & one exceptions will appear in the log"); start(PostgresConnector.class, config, (success, msg, error) -> { assertThat(success).isFalse(); assertThat(error).isNotNull(); }); assertConnectorNotRunning(); }
/** * Verifies that the connector doesn't run with an invalid configuration. This does not actually connect to the MySQL server. */ @Test public void shouldNotStartWithInvalidConfiguration() { config = Configuration.create() .with(MongoDbConnectorConfig.AUTO_DISCOVER_MEMBERS, "true") .build(); // we expect the engine will log at least one error, so preface it ... logger.info("Attempting to start the connector with an INVALID configuration, so MULTIPLE error messages & one exceptions will appear in the log"); start(MongoDbConnector.class, config, (success, msg, error) -> { assertThat(success).isFalse(); assertThat(error).isNotNull(); }); assertConnectorNotRunning(); }
/** * Verifies that the connector doesn't run with an invalid configuration. This does not actually connect to the MySQL server. */ @Test public void shouldNotStartWithInvalidConfiguration() { config = Configuration.create() .with(MySqlConnectorConfig.SERVER_NAME, "myserver") .with(KafkaDatabaseHistory.TOPIC, "myserver") .with(MySqlConnectorConfig.DATABASE_HISTORY, FileDatabaseHistory.class) .with(FileDatabaseHistory.FILE_PATH, DB_HISTORY_PATH) .build(); // we expect the engine will log at least one error, so preface it ... logger.info("Attempting to start the connector with an INVALID configuration, so MULTIPLE error messages and exceptions will appear in the log"); start(MySqlConnector.class, config, (success, msg, error) -> { assertThat(success).isFalse(); assertThat(error).isNotNull(); }); assertConnectorNotRunning(); }
@Test public void shouldThrowWhenMerchantNotFound() { when(merchantRepository.findByNumber(merchantNumber)).thenThrow(new NotFoundException()); //catchException(bookKeeper, NotFoundException.class).registerPaybackFor(...); assertThat(caughtException()).isNotNull(); }
@Test public void shouldThrowWhenAccountNotFound() { Purchase purchase = new Purchase(Money.of(EUR, 100L), "4321432143214321", merchantNumber, now()); catchException(bookKeeper, EmptyResultDataAccessException.class).registerPaybackFor(purchase); assertThat(caughtException()).isNotNull(); }
@Test public void shouldThrowWhenMerchantNotFound() { Purchase purchase = new Purchase(Money.of(EUR, 100L), creditCardNumber, "1111111111", now()); catchException(bookKeeper, EmptyResultDataAccessException.class).registerPaybackFor(purchase); assertThat(caughtException()).isNotNull(); }
@Test public void shouldThrowWhenMerchantNotFound() { purchase = new Purchase(Money.of(EUR, 100L), creditCardNumber, "1111111111", now()); catchException(bookKeeper, EmptyResultDataAccessException.class).registerPaybackFor(purchase); assertThat(caughtException()).isNotNull(); }
@Test public void shouldThrowWhenMerchantNotFound() { catchException(repository, EmptyResultDataAccessException.class).findByNumber("111111111"); assertThat(caughtException()).isNotNull(); }
@Test public void shouldThrowWhenAccountNotFound() { Purchase purchase = new Purchase(Money.of(EUR, 100L), "4321432143214321", merchantNumber, now()); catchException(bookKeeper, EmptyResultDataAccessException.class).registerPaybackFor(purchase); assertThat(caughtException()).isNotNull(); }
@Test public void shouldThrowWhenAccountNotFound() { purchase = new Purchase(Money.of(EUR, 100L), "4321432143214321", merchantNumber, now()); catchException(bookKeeper, EmptyResultDataAccessException.class).registerPaybackFor(purchase); assertThat(caughtException()).isNotNull(); }
@Test public void shouldThrowWhenMerchantNotFound() { purchase = new Purchase(Money.of(EUR, 100L), creditCardNumber, "1111111111", now()); catchException(bookKeeper, EmptyResultDataAccessException.class).registerPaybackFor(purchase); assertThat(caughtException()).isNotNull(); }
@Test public void shouldThrowWhenAccountNotFound() { purchase = new Purchase(Money.of(EUR, 100L), "4321432143214321", merchantNumber, now()); catchException(bookKeeper, EmptyResultDataAccessException.class).registerPaybackFor(purchase); assertThat(caughtException()).isNotNull(); }
@Test public void shouldThrowWhenMerchantNotFound() { purchase = new Purchase(Money.of(EUR, 100L), creditCardNumber, "1111111111", now()); catchException(bookKeeper, EmptyResultDataAccessException.class).registerPaybackFor(purchase); assertThat(caughtException()).isNotNull(); }
@Test public void shouldThrowWhenAccountNotFound() { Purchase purchase = new Purchase(Money.of(EUR, 100L), "4321432143214321", merchantNumber, now()); catchException(bookKeeper, EmptyResultDataAccessException.class).registerPaybackFor(purchase); assertThat(caughtException()).isNotNull(); }
@Test public void shouldThrowWhenMerchantNotFound() { catchException(repository, EmptyResultDataAccessException.class).findByNumber("111111111"); assertThat(caughtException()).isNotNull(); }
@Test public void shouldRegisterPaybackInTransaction() throws Exception { doThrow(new RuntimeException("DB error!")) .when(paybackRepository).save(any(AccountIncome.class), any(Purchase.class)); catchException(bookKeeper, RuntimeException.class).registerPaybackFor(purchase()); assertThat(caughtException()).isNotNull(); assertThat(paybackRepository.findByAccountNumber(accountNumber)).isEmpty(); for (Objective objective : accountRepository.findByCreditCardsNumber(creditCardNumber).getObjectives()) { assertThat(objective.getSavings()).isEqualTo(Money.zero(EUR)); } } }
@Test public void shouldNotStartWithInvalidConfiguration() throws Exception { // use an empty configuration which should be invalid because of the lack of DB connection details Configuration config = Configuration.create().build(); // we expect the engine will log at least one error, so preface it ... logger.info("Attempting to start the connector with an INVALID configuration, so MULTIPLE error messages & one exceptions will appear in the log"); start(PostgresConnector.class, config, (success, msg, error) -> { assertThat(success).isFalse(); assertThat(error).isNotNull(); }); assertConnectorNotRunning(); }
@Test public void shouldClearCacheOnShutdown() { tearDown(); catchException(repository, EmptyResultDataAccessException.class).findByNumber("1234567890"); assertThat(caughtException()).isNotNull(); }
@Test public void shouldClearCacheOnShutdown() { tearDown(); catchException(repository, EmptyResultDataAccessException.class).findByNumber("1234567890"); assertThat(caughtException()).isNotNull(); }
@Test public void shouldClearCacheOnShutdown() { tearDown(); catchException(repository, EmptyResultDataAccessException.class).findByNumber("1234567890"); assertThat(caughtException()).isNotNull(); }