DATACMNS-1554 - Polishing.

Replace AtTest(expected = …) and ExpectedException with the corresponding AssertJ assertThatExceptionOfType(…) and assertThatIllegalArgumentException().isThrownBy(…).
This commit is contained in:
Mark Paluch
2019-07-10 11:47:46 +02:00
parent 660006b8c9
commit 704913c866
79 changed files with 457 additions and 474 deletions

View File

@@ -86,13 +86,14 @@ public class ClassGeneratingEntityInstantiatorUnitTests<P extends PersistentProp
.satisfies(it -> verify(provider, times(1)).getParameterValue(it.getParameters().iterator().next()));
}
@Test(expected = MappingInstantiationException.class) // DATACMNS-300, DATACMNS-578
@Test // DATACMNS-300, DATACMNS-578
@SuppressWarnings({ "unchecked", "rawtypes" })
public void throwsExceptionOnBeanInstantiationException() {
doReturn(PersistentEntity.class).when(entity).getType();
this.instance.createInstance(entity, provider);
assertThatExceptionOfType(MappingInstantiationException.class)
.isThrownBy(() -> this.instance.createInstance(entity, provider));
}
@Test // DATACMNS-134, DATACMNS-578

View File

@@ -45,19 +45,19 @@ public class ConfigurableTypeInformationMapperUnitTests<T extends PersistentProp
mapper = new ConfigurableTypeInformationMapper(Collections.singletonMap(String.class, "1"));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullTypeMap() {
new ConfigurableTypeInformationMapper(null);
assertThatIllegalArgumentException().isThrownBy(() -> new ConfigurableTypeInformationMapper(null));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNonBijectionalMap() {
Map<Class<?>, String> map = new HashMap<>();
map.put(String.class, "1");
map.put(Object.class, "1");
new ConfigurableTypeInformationMapper(map);
assertThatIllegalArgumentException().isThrownBy(() -> new ConfigurableTypeInformationMapper(map));
}
@Test

View File

@@ -38,9 +38,9 @@ public class EntityInstantiatorsUnitTests {
@Mock PersistentEntity<?, ?> entity;
@Mock EntityInstantiator customInstantiator;
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullFallbackInstantiator() {
new EntityInstantiators((EntityInstantiator) null);
assertThatIllegalArgumentException().isThrownBy(() -> new EntityInstantiators((EntityInstantiator) null));
}
@Test

View File

@@ -45,9 +45,9 @@ public class MappingContextTypeInformationMapperUnitTests {
mappingContext = new SampleMappingContext();
}
@Test(expected = IllegalArgumentException.class)
@Test
public void rejectsNullMappingContext() {
new MappingContextTypeInformationMapper(null);
assertThatIllegalArgumentException().isThrownBy(() -> new MappingContextTypeInformationMapper(null));
}
@Test

View File

@@ -80,13 +80,14 @@ public class ReflectionEntityInstantiatorUnitTests<P extends PersistentProperty<
.satisfies(it -> verify(provider, times(1)).getParameterValue(it.getParameters().iterator().next()));
}
@Test(expected = MappingInstantiationException.class) // DATACMNS-300
@Test // DATACMNS-300
@SuppressWarnings({ "unchecked", "rawtypes" })
public void throwsExceptionOnBeanInstantiationException() {
doReturn(PersistentEntity.class).when(entity).getType();
INSTANCE.createInstance(entity, provider);
assertThatExceptionOfType(MappingInstantiationException.class)
.isThrownBy(() -> INSTANCE.createInstance(entity, provider));
}
@Test // DATACMNS-134