@Test
public void testMergeBatches() {

	// create two batch for the same system entity
	SysSystemDto system = getHelper().createSystem(TestResource.TABLE_NAME);
	SysSystemEntityDto systemEntity = getHelper().createSystemEntity(system);
	//
	SysProvisioningBatchDto batchOne = new SysProvisioningBatchDto();
	batchOne.setId(UUID.randomUUID());
	batchOne.setSystemEntity(systemEntity.getId());
	batchOne = batchService.save(batchOne);
	SysProvisioningOperationDto operationOne = createOperation(systemEntity, batchOne);
	//
	SysProvisioningBatchDto batchTwo = new SysProvisioningBatchDto();
	batchTwo.setId(UUID.randomUUID());
	batchTwo.setSystemEntity(systemEntity.getId());
	batchTwo = batchService.save(batchTwo);
	SysProvisioningOperationDto operationTwo = createOperation(systemEntity, batchTwo);
	//
	Assert.assertNotEquals(batchOne.getId(), batchTwo.getId());
	//
	SysProvisioningBatchDto mergedBatch = batchService.findBatch(systemEntity.getId());
	//
	Assert.assertEquals(batchOne.getId(), mergedBatch.getId());
	//
	Assert.assertNull(batchService.get(batchTwo));
	operationOne = operationService.get(operationOne.getId());
	operationTwo = operationService.get(operationTwo.getId());
	Assert.assertEquals(batchOne.getId(), operationOne.getBatch());
	Assert.assertEquals(batchOne.getId(), operationTwo.getBatch());
}