amendments according to self-review

This commit is contained in:
Michael Hoennig 2024-02-01 09:05:16 +01:00
parent 745765022e
commit c1490e5901
6 changed files with 12 additions and 9 deletions

View File

@ -110,6 +110,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
}
if (partnerRepo.deleteByUuid(partnerUuid) != 1 ||
// TODO: move to after delete trigger in partner
relationshipRepo.deleteByUuid(partnerToDelete.get().getPartnerRole().getUuid()) != 1 ) {
ResponseEntity.internalServerError().build();
}
@ -159,7 +160,7 @@ public class HsOfficePartnerController implements HsOfficePartnersApi {
private <E extends HasUuid> E ref(final Class<E> entityClass, final UUID uuid) {
try {
final var e = em.getReference(entityClass, uuid);
em.contains(e);
em.contains(e); // TODO: check if this is really needed to force an exception if not existing
return e;
} catch (final Throwable exc) {
throw new ReferenceNotFoundException(entityClass, uuid, exc);

View File

@ -10,10 +10,10 @@ public interface RbacRoleRepository extends Repository<RbacRoleEntity, UUID> {
/**
* @return the number of persistent RbacRoleEntity instances, mostly for testing purposes.
*/
long count();
long count(); // TODO: move to test sources
/**
* @return all persistent RbacRoleEntity instances, mostly for testing purposes.
* @return all persistent RbacRoleEntity instances, assigned to the current subject (user or assumed roles)
*/
List<RbacRoleEntity> findAll();

View File

@ -120,7 +120,7 @@ $$;
create table RbacObject
(
uuid uuid primary key default uuid_generate_v4(),
serialId serial,
serialId serial, -- TODO: we might want to remove this once test data deletion works properly
objectTable varchar(64) not null,
unique (objectTable, uuid)
);

View File

@ -524,8 +524,9 @@ public class ImportOfficeData extends ContextBasedTest {
try {
//System.out.println("persisting #" + entity.hashCode() + ": " + entity);
em.persist(entity);
//em.flush();
//System.out.println("persisted #" + entity.hashCode() + " as " + entity.getUuid());
// uncomment for debugging purposes
// em.flush();
// System.out.println("persisted #" + entity.hashCode() + " as " + entity.getUuid());
} catch (Exception exc) {
System.err.println("failed to persist #" + entity.hashCode() + ": " + entity);
System.err.println(exc);
@ -896,7 +897,7 @@ public class ImportOfficeData extends ContextBasedTest {
contractualMissing.add(partner.getPartnerNumber());
}
});
// assertThat(contractualMissing).isEmpty();
// assertThat(contractualMissing).isEmpty(); uncomment if we don't want allow missing contractual contact
}
private static boolean containsRole(final Record rec, final String role) {
final var roles = rec.getString("roles");

View File

@ -491,8 +491,9 @@ class HsOfficePartnerControllerAcceptanceTest extends ContextBasedTestWithCleanu
@AfterEach
void cleanup() {
cleanupAllNew(HsOfficePartnerDetailsEntity.class); // TODO: should not be necessary
cleanupAllNew(HsOfficePartnerEntity.class);
// TODO: should not be necessary anymore, once it's deleted via after delete trigger
cleanupAllNew(HsOfficeRelationshipEntity.class);
}
}

View File

@ -24,7 +24,7 @@ import static java.util.stream.Collectors.toSet;
import static org.apache.commons.collections4.SetUtils.difference;
import static org.assertj.core.api.Assertions.assertThat;
//@DirtiesContext
// TODO: cleanup the whole class
public abstract class ContextBasedTestWithCleanup extends ContextBasedTest {
private static final boolean DETAILED_BUT_SLOW_CHECK = true;