test_class.declarator: operationService
test_class.modifier: @Autowired private
test_class.original_string: @Autowired private SysProvisioningOperationService operationService;
test_class.type: SysProvisioningOperationService
test_class.var_name: operationService
test_class.declarator: batchService
test_class.modifier: @Autowired private
test_class.original_string: @Autowired private SysProvisioningBatchService batchService;
test_class.type: SysProvisioningBatchService
test_class.var_name: batchService
test_class.file: Realization/backend/acc/src/test/java/eu/bcvsolutions/idm/acc/service/impl/DefaultSysProvisioningBatchServiceTest.java
test_class.identifier: DefaultSysProvisioningBatchServiceTest
test_class.superclass: extends AbstractIntegrationTest
test_case.body: @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());
  	}
test_case.class_method_signature: DefaultSysProvisioningBatchServiceTest.testMergeBatches()
test_case.full_signature: @Test public void testMergeBatches()
test_case.identifier: testMergeBatches
test_case.invocations: createSystem getHelper createSystemEntity getHelper setId randomUUID setSystemEntity getId save createOperation setId randomUUID setSystemEntity getId save createOperation assertNotEquals getId getId findBatch getId assertEquals getId getId assertNull get get getId get getId assertEquals getId getBatch assertEquals getId getBatch
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testMergeBatches()
focal_class.declarator: LOG = org.slf4j.LoggerFactory.getLogger(DefaultSysProvisioningBatchService.class)
focal_class.modifier: private static final
focal_class.original_string: private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(DefaultSysProvisioningBatchService.class);
focal_class.type: org.slf4j.Logger
focal_class.var_name: LOG
focal_class.declarator: repository
focal_class.modifier: private final
focal_class.original_string: private final SysProvisioningBatchRepository repository;
focal_class.type: SysProvisioningBatchRepository
focal_class.var_name: repository
focal_class.declarator: provisioningConfiguration
focal_class.modifier: @Autowired private
focal_class.original_string: @Autowired private ProvisioningConfiguration provisioningConfiguration;
focal_class.type: ProvisioningConfiguration
focal_class.var_name: provisioningConfiguration
focal_class.file: Realization/backend/acc/src/main/java/eu/bcvsolutions/idm/acc/service/impl/DefaultSysProvisioningBatchService.java
focal_class.identifier: DefaultSysProvisioningBatchService
focal_class.interfaces: implements SysProvisioningBatchService
focal_class.class_method_signature: DefaultSysProvisioningBatchService.DefaultSysProvisioningBatchService(SysProvisioningBatchRepository repository)
focal_class.full_signature: @Autowired public  DefaultSysProvisioningBatchService(SysProvisioningBatchRepository repository)
focal_class.identifier: DefaultSysProvisioningBatchService
focal_class.modifiers: @Autowired public
focal_class.parameters: (SysProvisioningBatchRepository repository)
focal_class.signature:  DefaultSysProvisioningBatchService(SysProvisioningBatchRepository repository)
focal_class.class_method_signature: DefaultSysProvisioningBatchService.calculateNextAttempt(SysProvisioningOperationDto operation)
focal_class.full_signature: @Override public ZonedDateTime calculateNextAttempt(SysProvisioningOperationDto operation)
focal_class.identifier: calculateNextAttempt
focal_class.modifiers: @Override public
focal_class.parameters: (SysProvisioningOperationDto operation)
focal_class.return: ZonedDateTime
focal_class.signature: ZonedDateTime calculateNextAttempt(SysProvisioningOperationDto operation)
focal_class.class_method_signature: DefaultSysProvisioningBatchService.findBatchesToProcess(Boolean virtualSystem, Pageable pageable)
focal_class.full_signature: @Override @Transactional(readOnly = true) public Page<SysProvisioningBatchDto> findBatchesToProcess(Boolean virtualSystem, Pageable pageable)
focal_class.identifier: findBatchesToProcess
focal_class.modifiers: @Override @Transactional(readOnly = true) public
focal_class.parameters: (Boolean virtualSystem, Pageable pageable)
focal_class.return: Page<SysProvisioningBatchDto>
focal_class.signature: Page<SysProvisioningBatchDto> findBatchesToProcess(Boolean virtualSystem, Pageable pageable)
focal_class.class_method_signature: DefaultSysProvisioningBatchService.findBatchesToRetry(ZonedDateTime date, Pageable pageable)
focal_class.full_signature: @Override @Transactional(readOnly = true) public Page<SysProvisioningBatchDto> findBatchesToRetry(ZonedDateTime date, Pageable pageable)
focal_class.identifier: findBatchesToRetry
focal_class.modifiers: @Override @Transactional(readOnly = true) public
focal_class.parameters: (ZonedDateTime date, Pageable pageable)
focal_class.return: Page<SysProvisioningBatchDto>
focal_class.signature: Page<SysProvisioningBatchDto> findBatchesToRetry(ZonedDateTime date, Pageable pageable)
focal_class.class_method_signature: DefaultSysProvisioningBatchService.findBatch(UUID systemEntity)
focal_class.full_signature: @Override @Transactional public SysProvisioningBatchDto findBatch(UUID systemEntity)
focal_class.identifier: findBatch
focal_class.modifiers: @Override @Transactional public
focal_class.parameters: (UUID systemEntity)
focal_class.return: SysProvisioningBatchDto
focal_class.signature: SysProvisioningBatchDto findBatch(UUID systemEntity)
focal_class.superclass: extends AbstractReadWriteDtoService<SysProvisioningBatchDto, SysProvisioningBatch, EmptyFilter>
focal_method.body: @Override
  	@Transactional
  	public SysProvisioningBatchDto findBatch(UUID systemEntity) {
  		List<SysProvisioningBatch> batches = repository.findAllBySystemEntity_IdOrderByCreatedAsc(systemEntity);
  		//
  		if (batches.isEmpty()) {
  			return null;
  		}
  		//
  		if (batches.size() == 1) {
  			// consistent state
  			return  toDto(batches.get(0));
  		}
  		//
  		// merge batches together - use the first as target
  		SysProvisioningBatch firstBatch = batches.get(0);
  		for (int index = 1; index < batches.size(); index ++) {
  			// update batch for other provisioning operations 
  			SysProvisioningBatch oldBatch = batches.get(index);
  			repository.mergeBatch(oldBatch, firstBatch);
  			deleteById(oldBatch.getId());
  		}
  		//
  		return toDto(firstBatch);
  	}
focal_method.class_method_signature: DefaultSysProvisioningBatchService.findBatch(UUID systemEntity)
focal_method.full_signature: @Override @Transactional public SysProvisioningBatchDto findBatch(UUID systemEntity)
focal_method.identifier: findBatch
focal_method.invocations: findAllBySystemEntity_IdOrderByCreatedAsc isEmpty size toDto get get size get mergeBatch deleteById getId toDto
focal_method.modifiers: @Override @Transactional public
focal_method.parameters: (UUID systemEntity)
focal_method.return: SysProvisioningBatchDto
focal_method.signature: SysProvisioningBatchDto findBatch(UUID systemEntity)