Commit dab649dc authored by Noel Alonso's avatar Noel Alonso
Browse files

Arregla tests

Se comprueba que el item guardado en caso de rollback fue el snapshot
parent 1c644892
Loading
Loading
Loading
Loading
+8 −16
Original line number Diff line number Diff line
@@ -304,8 +304,6 @@ public abstract class SettingsEventHandlerBase extends IntegrationTestBase {

		event.setLastSnapshotItem(null);

		repository.save(lastSnapshotSettings);

		ListenableFuture<SendResult<String, Event>> future = kafkaTemplate.send(SETTINGS_TOPIC, event.getAggregateId(),
				event);
		future.addCallback(new SendListener());
@@ -318,7 +316,7 @@ public abstract class SettingsEventHandlerBase extends IntegrationTestBase {
		repository.findById(lastSnapshotSettings.getId()).get_source();
	}

	@Test
	@Test(expected = ItemNotFoundException.class)
	public void sendSettingsRollbackEvent_PublishSaveSettingsFailedEventAndDoRollback_IfFailEventTypeIsSaveAndLastSnapshotItemIsDifferent()
			throws Exception {

@@ -326,10 +324,7 @@ public abstract class SettingsEventHandlerBase extends IntegrationTestBase {

		Settings lastSnapshotSettings = Mappers.getMapper(SettingsESMapper.class).map(event.getLastSnapshotItem());

		lastSnapshotSettings.setUpdated(DateTime.now());
		lastSnapshotSettings.setName("other");

		assertNotEquals(event.getLastSnapshotItem(), lastSnapshotSettings);
		event.setLastSnapshotItem(null);

		repository.save(lastSnapshotSettings);

@@ -342,10 +337,7 @@ public abstract class SettingsEventHandlerBase extends IntegrationTestBase {
		assertNotNull(confirm);
		assertEquals(SettingsEventTypes.SAVE_FAILED, confirm.getType());

		Settings newSettings = (Settings) repository.findById(lastSnapshotSettings.getId()).get_source();
		assertEquals(lastSnapshotSettings, newSettings);

		repository.delete(lastSnapshotSettings.getId());
		repository.findById(lastSnapshotSettings.getId()).get_source();
	}

	@Test
@@ -431,7 +423,7 @@ public abstract class SettingsEventHandlerBase extends IntegrationTestBase {

		Settings lastSnapshotSettings = Mappers.getMapper(SettingsESMapper.class).map(event.getLastSnapshotItem());

		lastSnapshotSettings.setUpdated(DateTime.now());
		lastSnapshotSettings.setUpdated(lastSnapshotSettings.getUpdated().plusDays(1));
		lastSnapshotSettings.setName("other");

		assertNotEquals(event.getLastSnapshotItem(), lastSnapshotSettings);
@@ -448,7 +440,7 @@ public abstract class SettingsEventHandlerBase extends IntegrationTestBase {
		assertEquals(SettingsEventTypes.SELECT_FAILED, confirm.getType());

		Settings newSettings = (Settings) repository.findById(lastSnapshotSettings.getId()).get_source();
		assertEquals(lastSnapshotSettings, newSettings);
		assertEquals(Mappers.getMapper(SettingsESMapper.class).map(event.getLastSnapshotItem()), newSettings);

		repository.delete(lastSnapshotSettings.getId());
	}
@@ -488,7 +480,7 @@ public abstract class SettingsEventHandlerBase extends IntegrationTestBase {

		Settings lastSnapshotSettings = Mappers.getMapper(SettingsESMapper.class).map(event.getLastSnapshotItem());

		lastSnapshotSettings.setUpdated(DateTime.now());
		lastSnapshotSettings.setUpdated(lastSnapshotSettings.getUpdated().plusDays(1));
		lastSnapshotSettings.setName("other");

		assertNotEquals(event.getLastSnapshotItem(), lastSnapshotSettings);
@@ -505,7 +497,7 @@ public abstract class SettingsEventHandlerBase extends IntegrationTestBase {
		assertEquals(SettingsEventTypes.DESELECT_FAILED, confirm.getType());

		Settings newSettings = (Settings) repository.findById(lastSnapshotSettings.getId()).get_source();
		assertEquals(lastSnapshotSettings, newSettings);
		assertEquals(Mappers.getMapper(SettingsESMapper.class).map(event.getLastSnapshotItem()), newSettings);

		repository.delete(lastSnapshotSettings.getId());
	}