Skip to content
Permalink
Browse files
added branches and employees to external references check
  • Loading branch information
mgeiss committed Sep 19, 2017
1 parent 86469a6 commit 6984777ab5bf9330cdbd28fa4a7aa6abeaa3e54d
Showing 2 changed files with 16 additions and 2 deletions.
@@ -329,6 +329,9 @@ public void shouldNotDeleteOfficeWithBranches() throws Exception {
this.organizationManager.addBranch(parent.getIdentifier(), branch);
this.eventRecorder.wait(EventConstants.OPERATION_POST_OFFICE, branch.getIdentifier());

final Office fetchedParent = this.organizationManager.findOfficeByIdentifier(parent.getIdentifier());
Assert.assertTrue(fetchedParent.getExternalReferences());

this.organizationManager.deleteOffice(parent.getIdentifier());
}

@@ -343,6 +346,9 @@ public void shouldNotDeleteOfficeWithEmployees() throws Exception {
this.organizationManager.createEmployee(employee);
this.eventRecorder.wait(EventConstants.OPERATION_POST_EMPLOYEE, employee.getIdentifier());

final Office fetchedOffice = this.organizationManager.findOfficeByIdentifier(office.getIdentifier());
Assert.assertTrue(fetchedOffice.getExternalReferences());

this.organizationManager.deleteOffice(office.getIdentifier());
}

@@ -112,7 +112,11 @@ public Optional<Office> findOfficeByIdentifier(final String identifier) {
final Optional<AddressEntity> addressEntityOptional = this.addressRepository.findByOffice(officeEntityOptional.get());
addressEntityOptional.ifPresent(addressEntity -> office.setAddress(AddressMapper.map(addressEntity)));

office.setExternalReferences(this.hasExternalReferences(office.getIdentifier()));
office.setExternalReferences(
this.branchExists(office.getIdentifier())
|| this.hasEmployees(office.getIdentifier())
|| this.hasExternalReferences(office.getIdentifier())
);
});

return officeOptional;
@@ -158,7 +162,11 @@ public List<Office> extractOfficeEntities(final Page<OfficeEntity> officeEntityP
final Optional<AddressEntity> addressEntityOptional = this.addressRepository.findByOffice(officeEntity);
addressEntityOptional.ifPresent(addressEntity -> office.setAddress(AddressMapper.map(addressEntity)));

office.setExternalReferences(this.hasExternalReferences(office.getIdentifier()));
office.setExternalReferences(
this.branchExists(office.getIdentifier())
|| this.hasEmployees(office.getIdentifier())
|| this.hasExternalReferences(office.getIdentifier())
);
});
return offices;
}

0 comments on commit 6984777

Please sign in to comment.