refactoring for implicit creation of dependend hosting-assets #108

Merged
hsh-michaelhoennig merged 22 commits from refactoring-for-implicit-creation-of-dependend-hosting-assets into master 2024-09-26 10:51:30 +02:00
2 changed files with 4 additions and 5 deletions
Showing only changes of commit 7c46fdb36d - Show all commits

View File

@ -87,8 +87,7 @@ abstract class Mapper extends ModelMapper {
}
public <E> E fetchEntity(final String propertyName, final Class<E> entityClass, final Object subEntityUuid) {
// using getReference would be more efficient, but results in very technical error messages
final var entity = em.find(entityClass, subEntityUuid); // FIXME: try getReference
final var entity = em.getReference(entityClass, subEntityUuid);
if (entity != null) {
return entity;
}

View File

@ -50,7 +50,7 @@ class MapperUnitTest {
@Test
void mapsBeanWithExistingSubEntity() {
final SourceBean givenSource = SourceBean.builder().a("1234").b("Text").s1(new SubSourceBean1(GIVEN_UUID)).build();
when(em.find(SubTargetBean1.class, GIVEN_UUID)).thenReturn(new SubTargetBean1(GIVEN_UUID, "xxx"));
when(em.getReference(SubTargetBean1.class, GIVEN_UUID)).thenReturn(new SubTargetBean1(GIVEN_UUID, "xxx"));
final var result = mapper.map(givenSource, TargetBean.class);
assertThat(result).usingRecursiveComparison().isEqualTo(
@ -81,7 +81,7 @@ class MapperUnitTest {
@Test
void mapsBeanWithSubEntityNotFound() {
final SourceBean givenSource = SourceBean.builder().a("1234").b("Text").s1(new SubSourceBean1(GIVEN_UUID)).build();
when(em.find(SubTargetBean1.class, GIVEN_UUID)).thenReturn(null);
when(em.getReference(SubTargetBean1.class, GIVEN_UUID)).thenReturn(null);
final var exception = catchThrowable(() ->
mapper.map(givenSource, TargetBean.class)
@ -94,7 +94,7 @@ class MapperUnitTest {
@Test
void mapsBeanWithSubEntityNotFoundAndDisplayName() {
final SourceBean givenSource = SourceBean.builder().a("1234").b("Text").s2(new SubSourceBean2(GIVEN_UUID)).build();
when(em.find(SubTargetBean2.class, GIVEN_UUID)).thenReturn(null);
when(em.getReference(SubTargetBean2.class, GIVEN_UUID)).thenReturn(null);
final var exception = catchThrowable(() ->
mapper.map(givenSource, TargetBean.class)