DATACMNS-1554 - Migrate tests to AssertJ.
This commit is contained in:
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.convert;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.Format;
|
||||
@@ -29,6 +27,7 @@ import java.util.Locale;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.core.convert.converter.ConverterFactory;
|
||||
@@ -38,6 +37,7 @@ import org.springframework.core.convert.support.GenericConversionService;
|
||||
import org.springframework.data.convert.ConverterBuilder.ConverterAware;
|
||||
import org.springframework.data.convert.CustomConversions.StoreConversions;
|
||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
|
||||
import org.threeten.bp.LocalDateTime;
|
||||
|
||||
/**
|
||||
@@ -93,7 +93,7 @@ public class CustomConversionsUnitTests {
|
||||
Arrays.asList(StringToFormatConverter.INSTANCE));
|
||||
conversions.registerConvertersIn(conversionService);
|
||||
|
||||
assertThat(conversionService.canConvert(String.class, Format.class), is(true));
|
||||
assertThat(conversionService.canConvert(String.class, Format.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-259, DATACMNS-1035
|
||||
@@ -101,7 +101,7 @@ public class CustomConversionsUnitTests {
|
||||
|
||||
CustomConversions conversions = new CustomConversions(StoreConversions.NONE,
|
||||
Arrays.asList(StringToFormatConverter.INSTANCE));
|
||||
assertThat(conversions.isSimpleType(Format.class), is(false));
|
||||
assertThat(conversions.isSimpleType(Format.class)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-298, DATACMNS-1035
|
||||
@@ -109,8 +109,8 @@ public class CustomConversionsUnitTests {
|
||||
|
||||
CustomConversions conversions = new CustomConversions(StoreConversions.NONE,
|
||||
Arrays.asList(StringToIntegerConverter.INSTANCE));
|
||||
assertThat(conversions.hasCustomReadTarget(String.class, Integer.class), is(true));
|
||||
assertThat(conversions.hasCustomWriteTarget(String.class, Integer.class), is(true));
|
||||
assertThat(conversions.hasCustomReadTarget(String.class, Integer.class)).isTrue();
|
||||
assertThat(conversions.hasCustomWriteTarget(String.class, Integer.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-795, DATACMNS-1035
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.domain;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.springframework.data.domain.ExampleMatcher.*;
|
||||
|
||||
import org.junit.Before;
|
||||
@@ -34,37 +33,37 @@ public class ExampleMatcherUnitTests {
|
||||
ExampleMatcher matcher;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
public void setUp() {
|
||||
matcher = matching();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void defaultStringMatcherShouldReturnDefault() throws Exception {
|
||||
public void defaultStringMatcherShouldReturnDefault() {
|
||||
assertThat(matcher.getDefaultStringMatcher()).isEqualTo(StringMatcher.DEFAULT);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void ignoreCaseShouldReturnFalseByDefault() throws Exception {
|
||||
public void ignoreCaseShouldReturnFalseByDefault() {
|
||||
assertThat(matcher.isIgnoreCaseEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void ignoredPathsIsEmptyByDefault() throws Exception {
|
||||
public void ignoredPathsIsEmptyByDefault() {
|
||||
assertThat(matcher.getIgnoredPaths()).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void nullHandlerShouldReturnIgnoreByDefault() throws Exception {
|
||||
public void nullHandlerShouldReturnIgnoreByDefault() {
|
||||
assertThat(matcher.getNullHandler()).isEqualTo(NullHandler.IGNORE);
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class) // DATACMNS-810
|
||||
public void ignoredPathsIsNotModifiable() throws Exception {
|
||||
public void ignoredPathsIsNotModifiable() {
|
||||
matcher.getIgnoredPaths().add("¯\\_(ツ)_/¯");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void ignoreCaseShouldReturnTrueWhenIgnoreCaseEnabled() throws Exception {
|
||||
public void ignoreCaseShouldReturnTrueWhenIgnoreCaseEnabled() {
|
||||
|
||||
matcher = matching().withIgnoreCase();
|
||||
|
||||
@@ -72,7 +71,7 @@ public class ExampleMatcherUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void ignoreCaseShouldReturnTrueWhenIgnoreCaseSet() throws Exception {
|
||||
public void ignoreCaseShouldReturnTrueWhenIgnoreCaseSet() {
|
||||
|
||||
matcher = matching().withIgnoreCase(true);
|
||||
|
||||
@@ -80,7 +79,7 @@ public class ExampleMatcherUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void nullHandlerShouldReturnInclude() throws Exception {
|
||||
public void nullHandlerShouldReturnInclude() {
|
||||
|
||||
matcher = matching().withIncludeNullValues();
|
||||
|
||||
@@ -88,7 +87,7 @@ public class ExampleMatcherUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void nullHandlerShouldReturnIgnore() throws Exception {
|
||||
public void nullHandlerShouldReturnIgnore() {
|
||||
|
||||
matcher = matching().withIgnoreNullValues();
|
||||
|
||||
@@ -96,7 +95,7 @@ public class ExampleMatcherUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void nullHandlerShouldReturnConfiguredValue() throws Exception {
|
||||
public void nullHandlerShouldReturnConfiguredValue() {
|
||||
|
||||
matcher = matching().withNullHandler(NullHandler.INCLUDE);
|
||||
|
||||
@@ -104,7 +103,7 @@ public class ExampleMatcherUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void ignoredPathsShouldReturnCorrectProperties() throws Exception {
|
||||
public void ignoredPathsShouldReturnCorrectProperties() {
|
||||
|
||||
matcher = matching().withIgnorePaths("foo", "bar", "baz");
|
||||
|
||||
@@ -113,7 +112,7 @@ public class ExampleMatcherUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void ignoredPathsShouldReturnUniqueProperties() throws Exception {
|
||||
public void ignoredPathsShouldReturnUniqueProperties() {
|
||||
|
||||
matcher = matching().withIgnorePaths("foo", "bar", "foo");
|
||||
|
||||
@@ -122,12 +121,12 @@ public class ExampleMatcherUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-810
|
||||
public void withCreatesNewInstance() throws Exception {
|
||||
public void withCreatesNewInstance() {
|
||||
|
||||
matcher = matching().withIgnorePaths("foo", "bar", "foo");
|
||||
ExampleMatcher configuredExampleSpec = matcher.withIgnoreCase();
|
||||
|
||||
assertThat(matcher).isNotEqualTo(sameInstance(configuredExampleSpec));
|
||||
assertThat(matcher).isNotSameAs(configuredExampleSpec);
|
||||
assertThat(matcher.getIgnoredPaths()).hasSize(2);
|
||||
assertThat(matcher.isIgnoreCaseEnabled()).isFalse();
|
||||
|
||||
@@ -157,31 +156,29 @@ public class ExampleMatcherUnitTests {
|
||||
}
|
||||
|
||||
@Test // DATACMNS-900
|
||||
public void shouldCompareUsingHashCodeAndEquals() throws Exception {
|
||||
public void shouldCompareUsingHashCodeAndEquals() {
|
||||
|
||||
matcher = matching() //
|
||||
.withIgnorePaths("foo", "bar", "baz") //
|
||||
.withNullHandler(NullHandler.IGNORE) //
|
||||
.withIgnoreCase("ignored-case") //
|
||||
.withMatcher("hello", GenericPropertyMatchers.contains().caseSensitive()) //
|
||||
.withMatcher("world", matcher -> matcher.endsWith());
|
||||
.withMatcher("world", GenericPropertyMatcher::endsWith);
|
||||
|
||||
ExampleMatcher sameAsMatcher = matching() //
|
||||
.withIgnorePaths("foo", "bar", "baz") //
|
||||
.withNullHandler(NullHandler.IGNORE) //
|
||||
.withIgnoreCase("ignored-case") //
|
||||
.withMatcher("hello", GenericPropertyMatchers.contains().caseSensitive()) //
|
||||
.withMatcher("world", matcher -> matcher.endsWith());
|
||||
.withMatcher("world", GenericPropertyMatcher::endsWith);
|
||||
|
||||
ExampleMatcher different = matching() //
|
||||
.withIgnorePaths("foo", "bar", "baz") //
|
||||
.withNullHandler(NullHandler.IGNORE) //
|
||||
.withMatcher("hello", GenericPropertyMatchers.contains().ignoreCase());
|
||||
|
||||
assertThat(matcher.hashCode()).isEqualTo(sameAsMatcher.hashCode());
|
||||
assertThat(matcher.hashCode()).isNotEqualTo(different.hashCode());
|
||||
assertThat(matcher).isEqualTo(sameAsMatcher);
|
||||
assertThat(matcher).isNotEqualTo(different);
|
||||
assertThat(matcher.hashCode()).isEqualTo(sameAsMatcher.hashCode()).isNotEqualTo(different.hashCode());
|
||||
assertThat(matcher).isEqualTo(sameAsMatcher).isNotEqualTo(different);
|
||||
}
|
||||
|
||||
static class Person {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.Assume.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -31,7 +30,6 @@ import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
@@ -39,6 +37,7 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
import org.springframework.data.annotation.AccessType;
|
||||
import org.springframework.data.annotation.AccessType.Type;
|
||||
@@ -192,21 +191,6 @@ public class BasicPersistentEntityUnitTests<T extends PersistentProperty<T>> {
|
||||
.hasMessageContaining("Required property foo not found");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-596
|
||||
public void returnsBeanWrapperForPropertyAccessor() {
|
||||
|
||||
assumeThat(System.getProperty("java.version"), CoreMatchers.startsWith("1.6"));
|
||||
|
||||
SampleMappingContext context = new SampleMappingContext();
|
||||
PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Entity.class);
|
||||
|
||||
Entity value = new Entity();
|
||||
PersistentPropertyAccessor<Entity> accessor = entity.getPropertyAccessor(value);
|
||||
|
||||
assertThat(accessor).isInstanceOf(BeanWrapper.class);
|
||||
assertThat(accessor.getBean()).isEqualTo(value);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-809
|
||||
public void returnsGeneratedPropertyAccessorForPropertyAccessor() {
|
||||
|
||||
|
||||
@@ -22,9 +22,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hamcrest.BaseMatcher;
|
||||
import org.hamcrest.Description;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.core.type.filter.AssignableTypeFilter;
|
||||
@@ -92,40 +91,5 @@ public class RepositoryComponentProviderUnitTests {
|
||||
assertThat(provider.getRegistry()).isEqualTo(registry);
|
||||
}
|
||||
|
||||
static class BeanDefinitionOfTypeMatcher extends BaseMatcher<BeanDefinition> {
|
||||
|
||||
private final Class<?> expectedType;
|
||||
|
||||
private BeanDefinitionOfTypeMatcher(Class<?> expectedType) {
|
||||
this.expectedType = expectedType;
|
||||
}
|
||||
|
||||
public static BeanDefinitionOfTypeMatcher beanDefinitionOfType(Class<?> expectedType) {
|
||||
return new BeanDefinitionOfTypeMatcher(expectedType);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.hamcrest.Matcher#matches(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean matches(Object item) {
|
||||
|
||||
if (!(item instanceof BeanDefinition)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BeanDefinition definition = (BeanDefinition) item;
|
||||
return definition.getBeanClassName().equals(expectedType.getName());
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.hamcrest.SelfDescribing#describeTo(org.hamcrest.Description)
|
||||
*/
|
||||
@Override
|
||||
public void describeTo(Description description) {}
|
||||
}
|
||||
|
||||
public interface MyNestedRepository extends Repository<Person, Long> {}
|
||||
}
|
||||
|
||||
@@ -15,14 +15,13 @@
|
||||
*/
|
||||
package org.springframework.data.repository.config;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.aop.TargetSource;
|
||||
import org.springframework.aop.framework.Advised;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
@@ -67,8 +66,8 @@ public class RepositoryConfigurationDelegateUnitTests {
|
||||
|
||||
BeanDefinition beanDefinition = definition.getBeanDefinition();
|
||||
|
||||
assertThat(beanDefinition.getAttribute(RepositoryConfigurationDelegate.FACTORY_BEAN_OBJECT_TYPE).toString(),
|
||||
endsWith("Repository"));
|
||||
assertThat(beanDefinition.getAttribute(RepositoryConfigurationDelegate.FACTORY_BEAN_OBJECT_TYPE).toString())
|
||||
.endsWith("Repository");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.repository.config;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -83,7 +82,7 @@ public class ResourceReaderRepositoryPopulatorBeanDefinitionParserIntegrationTes
|
||||
|
||||
assertThat(source).isInstanceOf(List.class);
|
||||
List<?> list = (List<?>) source;
|
||||
assertThat(list).isNotEqualTo(empty());
|
||||
assertThat(list).isNotEmpty();
|
||||
Object element = list.get(0);
|
||||
assertThat(element).isInstanceOf(ClassPathResource.class);
|
||||
ClassPathResource resource = (ClassPathResource) element;
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.repository.core.support;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.Flowable;
|
||||
@@ -29,6 +28,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||
@@ -52,8 +52,8 @@ public class ReactiveRepositoryInformationUnitTests {
|
||||
|
||||
Method reference = extractTargetMethodFromRepository(RxJava1InterfaceWithGenerics.class, "deleteAll");
|
||||
|
||||
assertEquals(ReactiveCrudRepository.class, reference.getDeclaringClass());
|
||||
assertThat(reference.getName(), is("deleteAll"));
|
||||
assertThat(reference.getDeclaringClass()).isEqualTo(ReactiveCrudRepository.class);
|
||||
assertThat(reference.getName()).isEqualTo("deleteAll");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
@@ -62,9 +62,9 @@ public class ReactiveRepositoryInformationUnitTests {
|
||||
Method reference = extractTargetMethodFromRepository(RxJava1InterfaceWithGenerics.class, "saveAll",
|
||||
Observable.class);
|
||||
|
||||
assertEquals(ReactiveCrudRepository.class, reference.getDeclaringClass());
|
||||
assertThat(reference.getName(), is("saveAll"));
|
||||
assertThat(reference.getParameterTypes()[0], is(equalTo(Publisher.class)));
|
||||
assertThat(reference.getDeclaringClass()).isEqualTo(ReactiveCrudRepository.class);
|
||||
assertThat(reference.getName()).isEqualTo("saveAll");
|
||||
assertThat(reference.getParameterTypes()[0]).isEqualTo(Publisher.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-988
|
||||
@@ -72,8 +72,8 @@ public class ReactiveRepositoryInformationUnitTests {
|
||||
|
||||
Method reference = extractTargetMethodFromRepository(RxJava2InterfaceWithGenerics.class, "deleteAll");
|
||||
|
||||
assertEquals(ReactiveCrudRepository.class, reference.getDeclaringClass());
|
||||
assertThat(reference.getName(), is("deleteAll"));
|
||||
assertThat(reference.getDeclaringClass()).isEqualTo(ReactiveCrudRepository.class);
|
||||
assertThat(reference.getName()).isEqualTo("deleteAll");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-988
|
||||
@@ -81,9 +81,9 @@ public class ReactiveRepositoryInformationUnitTests {
|
||||
|
||||
Method reference = extractTargetMethodFromRepository(RxJava2InterfaceWithGenerics.class, "saveAll", Flowable.class);
|
||||
|
||||
assertEquals(ReactiveCrudRepository.class, reference.getDeclaringClass());
|
||||
assertThat(reference.getName(), is("saveAll"));
|
||||
assertThat(reference.getParameterTypes()[0], is(equalTo(Publisher.class)));
|
||||
assertThat(reference.getDeclaringClass()).isEqualTo(ReactiveCrudRepository.class);
|
||||
assertThat(reference.getName()).isEqualTo("saveAll");
|
||||
assertThat(reference.getParameterTypes()[0]).isEqualTo(Publisher.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
@@ -91,9 +91,9 @@ public class ReactiveRepositoryInformationUnitTests {
|
||||
|
||||
Method reference = extractTargetMethodFromRepository(ReactiveSortingRepository.class, "saveAll", Publisher.class);
|
||||
|
||||
assertEquals(ReactiveCrudRepository.class, reference.getDeclaringClass());
|
||||
assertThat(reference.getName(), is("saveAll"));
|
||||
assertThat(reference.getParameterTypes()[0], is(equalTo(Publisher.class)));
|
||||
assertThat(reference.getDeclaringClass()).isEqualTo(ReactiveCrudRepository.class);
|
||||
assertThat(reference.getName()).isEqualTo("saveAll");
|
||||
assertThat(reference.getParameterTypes()[0]).isEqualTo(Publisher.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
@@ -102,9 +102,9 @@ public class ReactiveRepositoryInformationUnitTests {
|
||||
Method reference = extractTargetMethodFromRepository(ReactiveJavaInterfaceWithGenerics.class, "saveAll",
|
||||
Iterable.class);
|
||||
|
||||
assertEquals(ReactiveCrudRepository.class, reference.getDeclaringClass());
|
||||
assertThat(reference.getName(), is("saveAll"));
|
||||
assertThat(reference.getParameterTypes()[0], is(equalTo(Iterable.class)));
|
||||
assertThat(reference.getDeclaringClass()).isEqualTo(ReactiveCrudRepository.class);
|
||||
assertThat(reference.getName()).isEqualTo("saveAll");
|
||||
assertThat(reference.getParameterTypes()[0]).isEqualTo(Iterable.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-836
|
||||
@@ -112,9 +112,9 @@ public class ReactiveRepositoryInformationUnitTests {
|
||||
|
||||
Method reference = extractTargetMethodFromRepository(ReactiveJavaInterfaceWithGenerics.class, "save", Object.class);
|
||||
|
||||
assertEquals(ReactiveCrudRepository.class, reference.getDeclaringClass());
|
||||
assertThat(reference.getName(), is("save"));
|
||||
assertThat(reference.getParameterTypes()[0], is(equalTo(Object.class)));
|
||||
assertThat(reference.getDeclaringClass()).isEqualTo(ReactiveCrudRepository.class);
|
||||
assertThat(reference.getName()).isEqualTo("save");
|
||||
assertThat(reference.getParameterTypes()[0]).isEqualTo(Object.class);
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1023
|
||||
@@ -122,7 +122,7 @@ public class ReactiveRepositoryInformationUnitTests {
|
||||
|
||||
Method reference = extractTargetMethodFromRepository(DummyRepository.class, "saveAll", Iterable.class);
|
||||
|
||||
assertThat(reference, is(ReactiveCrudRepository.class.getMethod("saveAll", Iterable.class)));
|
||||
assertThat(reference).isEqualTo(ReactiveCrudRepository.class.getMethod("saveAll", Iterable.class));
|
||||
}
|
||||
|
||||
private Method extractTargetMethodFromRepository(Class<?> repositoryType, String methodName, Class<?>... args)
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.repository.core.support;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.*;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -62,7 +61,7 @@ public class SurroundingTransactionDetectorMethodInterceptorUnitTests {
|
||||
*/
|
||||
public Object proceed() throws Throwable {
|
||||
|
||||
assertThat(INSTANCE.isSurroundingTransactionActive(), is(transactionActive));
|
||||
assertThat(INSTANCE.isSurroundingTransactionActive()).isEqualTo(transactionActive);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
package org.springframework.data.repository.query;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assume.*;
|
||||
|
||||
import io.vavr.collection.Seq;
|
||||
import io.vavr.control.Option;
|
||||
@@ -30,7 +28,7 @@ import java.util.concurrent.Future;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.SpringVersion;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
@@ -40,7 +38,6 @@ import org.springframework.data.repository.Repository;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.core.support.AbstractRepositoryMetadata;
|
||||
import org.springframework.data.repository.core.support.DefaultRepositoryMetadata;
|
||||
import org.springframework.data.util.Version;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link QueryMethod}.
|
||||
@@ -51,9 +48,6 @@ import org.springframework.data.util.Version;
|
||||
*/
|
||||
public class QueryMethodUnitTests {
|
||||
|
||||
private static final Version SPRING_VERSION = Version.parse(SpringVersion.getVersion());
|
||||
private static final Version FOUR_DOT_TWO = new Version(4, 2);
|
||||
|
||||
RepositoryMetadata metadata = new DefaultRepositoryMetadata(SampleRepository.class);
|
||||
ProjectionFactory factory = new SpelAwareProxyProjectionFactory();
|
||||
|
||||
@@ -160,8 +154,6 @@ public class QueryMethodUnitTests {
|
||||
@Test // DATACMNS-716
|
||||
public void doesNotRejectCompletableFutureQueryForEntityCollection() throws Exception {
|
||||
|
||||
assumeThat(SPRING_VERSION.isGreaterThanOrEqualTo(FOUR_DOT_TWO), is(true));
|
||||
|
||||
RepositoryMetadata repositoryMetadata = new DefaultRepositoryMetadata(SampleRepository.class);
|
||||
Method method = SampleRepository.class.getMethod("returnsCompletableFutureForEntityCollection");
|
||||
|
||||
|
||||
@@ -18,14 +18,15 @@ package org.springframework.data.transaction;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.transaction.ChainedTransactionManagerTests.TestPlatformTransactionManager.*;
|
||||
|
||||
import org.hamcrest.Factory;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.transaction.HeuristicCompletionException;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionException;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.UnexpectedRollbackException;
|
||||
import org.springframework.transaction.support.AbstractTransactionStatus;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
|
||||
/**
|
||||
@@ -40,7 +41,7 @@ public class ChainedTransactionManagerTests {
|
||||
ChainedTransactionManager tm;
|
||||
|
||||
@Test
|
||||
public void shouldCompleteSuccessfully() throws Exception {
|
||||
public void shouldCompleteSuccessfully() {
|
||||
|
||||
TestPlatformTransactionManager transactionManager = createNonFailingTransactionManager("single");
|
||||
setupTransactionManagers(transactionManager);
|
||||
@@ -51,7 +52,7 @@ public class ChainedTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldThrowRolledBackExceptionForSingleTMFailure() throws Exception {
|
||||
public void shouldThrowRolledBackExceptionForSingleTMFailure() {
|
||||
|
||||
setupTransactionManagers(createFailingTransactionManager("single"));
|
||||
|
||||
@@ -86,7 +87,7 @@ public class ChainedTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldThrowMixedRolledBackExceptionForNonFirstTMFailure() throws Exception {
|
||||
public void shouldThrowMixedRolledBackExceptionForNonFirstTMFailure() {
|
||||
|
||||
setupTransactionManagers(TestPlatformTransactionManager.createFailingTransactionManager("first"),
|
||||
createNonFailingTransactionManager("second"));
|
||||
@@ -97,7 +98,7 @@ public class ChainedTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRollbackAllTransactionManagers() throws Exception {
|
||||
public void shouldRollbackAllTransactionManagers() {
|
||||
|
||||
TestPlatformTransactionManager first = createNonFailingTransactionManager("first");
|
||||
TestPlatformTransactionManager second = createNonFailingTransactionManager("second");
|
||||
@@ -111,7 +112,7 @@ public class ChainedTransactionManagerTests {
|
||||
}
|
||||
|
||||
@Test(expected = UnexpectedRollbackException.class)
|
||||
public void shouldThrowExceptionOnFailingRollback() throws Exception {
|
||||
public void shouldThrowExceptionOnFailingRollback() {
|
||||
|
||||
PlatformTransactionManager first = createFailingTransactionManager("first");
|
||||
setupTransactionManagers(first);
|
||||
@@ -159,7 +160,6 @@ public class ChainedTransactionManagerTests {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Factory
|
||||
static TestPlatformTransactionManager createFailingTransactionManager(String name) {
|
||||
return new TestPlatformTransactionManager(name + "-failing") {
|
||||
@Override
|
||||
@@ -174,7 +174,6 @@ public class ChainedTransactionManagerTests {
|
||||
};
|
||||
}
|
||||
|
||||
@Factory
|
||||
static TestPlatformTransactionManager createNonFailingTransactionManager(String name) {
|
||||
return new TestPlatformTransactionManager(name + "-non-failing");
|
||||
}
|
||||
@@ -208,45 +207,14 @@ public class ChainedTransactionManagerTests {
|
||||
return commitTime;
|
||||
}
|
||||
|
||||
static class TestTransactionStatus implements org.springframework.transaction.TransactionStatus {
|
||||
}
|
||||
|
||||
public TestTransactionStatus(TransactionDefinition definition) {}
|
||||
static class TestTransactionStatus extends AbstractTransactionStatus {
|
||||
|
||||
public boolean isNewTransaction() {
|
||||
return false;
|
||||
}
|
||||
public TestTransactionStatus(TransactionDefinition definition) {}
|
||||
|
||||
public boolean hasSavepoint() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setRollbackOnly() {
|
||||
|
||||
}
|
||||
|
||||
public boolean isRollbackOnly() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
|
||||
}
|
||||
|
||||
public boolean isCompleted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object createSavepoint() throws TransactionException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void rollbackToSavepoint(Object savepoint) throws TransactionException {
|
||||
|
||||
}
|
||||
|
||||
public void releaseSavepoint(Object savepoint) throws TransactionException {
|
||||
|
||||
}
|
||||
public boolean isNewTransaction() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,20 +17,16 @@ package org.springframework.data.util;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link Version}.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class VersionUnitTests {
|
||||
|
||||
public @Rule ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Test // DATCMNS-384
|
||||
public void sameVersionsEqualOneDigits() {
|
||||
|
||||
@@ -133,13 +129,13 @@ public class VersionUnitTests {
|
||||
@Test // DATCMNS-384
|
||||
public void removesTrailingZerosAfterSecondValueForToString() {
|
||||
|
||||
assertThat(new Version(2).toString()).isEqualTo("2.0");
|
||||
assertThat(new Version(2, 0).toString()).isEqualTo("2.0");
|
||||
assertThat(new Version(2, 0, 0).toString()).isEqualTo("2.0");
|
||||
assertThat(new Version(2, 0, 0, 0).toString()).isEqualTo("2.0");
|
||||
assertThat(new Version(2, 0, 1).toString()).isEqualTo("2.0.1");
|
||||
assertThat(new Version(2, 0, 1, 0).toString()).isEqualTo("2.0.1");
|
||||
assertThat(new Version(2, 0, 0, 1).toString()).isEqualTo("2.0.0.1");
|
||||
assertThat(new Version(2)).hasToString("2.0");
|
||||
assertThat(new Version(2, 0)).hasToString("2.0");
|
||||
assertThat(new Version(2, 0, 0)).hasToString("2.0");
|
||||
assertThat(new Version(2, 0, 0, 0)).hasToString("2.0");
|
||||
assertThat(new Version(2, 0, 1)).hasToString("2.0.1");
|
||||
assertThat(new Version(2, 0, 1, 0)).hasToString("2.0.1");
|
||||
assertThat(new Version(2, 0, 0, 1)).hasToString("2.0.0.1");
|
||||
}
|
||||
|
||||
@Test // DATACMNS-496
|
||||
@@ -155,10 +151,7 @@ public class VersionUnitTests {
|
||||
@Test // DATACMNS-719, DATACMNS-496
|
||||
public void rejectsNonNumericPartOnNonLastPosition() {
|
||||
|
||||
exception.expect(IllegalArgumentException.class);
|
||||
exception.expectCause(Matchers.instanceOf(IllegalArgumentException.class));
|
||||
exception.expectMessage("1.RELEASE.2");
|
||||
|
||||
Version.parse("1.RELEASE.2");
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> Version.parse("1.RELEASE.2"))
|
||||
.withMessageContaining("1.RELEASE.2");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user