DATAREST-1008 - Adapt to API changes in Spring Data Commons, Java 8 upgrades and Mockito 2.7.
This commit is contained in:
0
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/AbstractIntegrationTests.java
Normal file → Executable file
0
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/AbstractIntegrationTests.java
Normal file → Executable file
21
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/PathUnitTests.java
Normal file → Executable file
21
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/PathUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -31,50 +30,50 @@ public class PathUnitTests {
|
||||
public void combinesSimplePaths() {
|
||||
|
||||
Path builder = new Path("foo").slash("bar");
|
||||
assertThat(builder.toString(), is("/foo/bar"));
|
||||
assertThat(builder.toString()).isEqualTo("/foo/bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removesLeadingAndTrailingSlashes() {
|
||||
|
||||
Path builder = new Path("foo/").slash("/bar").slash("//foobar///");
|
||||
assertThat(builder.toString(), is("/foo/bar/foobar"));
|
||||
assertThat(builder.toString()).isEqualTo("/foo/bar/foobar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removesWhitespace() {
|
||||
|
||||
Path builder = new Path("foo/ ").slash("/ b a r").slash(" //foobar/// ");
|
||||
assertThat(builder.toString(), is("/foo/bar/foobar"));
|
||||
assertThat(builder.toString()).isEqualTo("/foo/bar/foobar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchesWithLeadingSlash() {
|
||||
assertThat(new Path("/foobar").matches("/foobar"), is(true));
|
||||
assertThat(new Path("/foobar").matches("/foobar")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void matchesWithoutLeadingSlash() {
|
||||
assertThat(new Path("/foobar").matches("foobar"), is(true));
|
||||
assertThat(new Path("/foobar").matches("foobar")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doesNotMatchIfDifferent() {
|
||||
assertThat(new Path("/foobar").matches("barfoo"), is(false));
|
||||
assertThat(new Path("/foobar").matches("barfoo")).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doesNotPrefixAbsoluteUris() {
|
||||
assertThat(new Path("http://localhost").toString(), is("http://localhost"));
|
||||
assertThat(new Path("http://localhost").toString()).isEqualTo("http://localhost");
|
||||
}
|
||||
|
||||
@Test // DATAREST-222
|
||||
public void doesNotMatchIfReferenceContainsReservedCharacters() {
|
||||
assertThat(new Path("/foobar").matches("barfoo{?foo}"), is(false));
|
||||
assertThat(new Path("/foobar").matches("barfoo{?foo}")).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-222
|
||||
public void doesNotMatchNullReference() {
|
||||
assertThat(new Path("/foobar").matches(null), is(false));
|
||||
assertThat(new Path("/foobar").matches(null)).isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
29
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/RepositoryRestConfigurationIntegrationTests.java
Normal file → Executable file
29
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/RepositoryRestConfigurationIntegrationTests.java
Normal file → Executable file
@@ -1,7 +1,21 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.rest.core;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -13,6 +27,7 @@ import org.springframework.data.rest.core.domain.ConfiguredPersonRepository;
|
||||
* Tests to check that {@link ResourceMapping}s are handled correctly.
|
||||
*
|
||||
* @author Jon Brisbin
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class RepositoryRestConfigurationIntegrationTests extends AbstractIntegrationTests {
|
||||
@@ -21,12 +36,12 @@ public class RepositoryRestConfigurationIntegrationTests extends AbstractIntegra
|
||||
|
||||
@Test
|
||||
public void shouldProvideResourceMappingForConfiguredRepository() throws Exception {
|
||||
|
||||
ResourceMapping mapping = config.getResourceMappingForRepository(ConfiguredPersonRepository.class);
|
||||
|
||||
assertThat(mapping, notNullValue());
|
||||
assertThat(mapping.getRel(), is("people"));
|
||||
assertThat(mapping.getPath(), is("people"));
|
||||
assertThat(mapping.isExported(), is(false));
|
||||
assertThat(mapping).isNotNull();
|
||||
assertThat(mapping.getRel()).isEqualTo("people");
|
||||
assertThat(mapping.getPath()).isEqualTo("people");
|
||||
assertThat(mapping.isExported()).isFalse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
45
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/RepositoryRestConfigurationUnitTests.java
Normal file → Executable file
45
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/RepositoryRestConfigurationUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -54,22 +53,22 @@ public class RepositoryRestConfigurationUnitTests {
|
||||
@Test // DATAREST-34
|
||||
public void returnsBodiesIfAcceptHeaderPresentByDefault() {
|
||||
|
||||
assertThat(configuration.returnBodyOnCreate(MediaType.APPLICATION_JSON_VALUE), is(true));
|
||||
assertThat(configuration.returnBodyOnUpdate(MediaType.APPLICATION_JSON_VALUE), is(true));
|
||||
assertThat(configuration.returnBodyOnCreate(MediaType.APPLICATION_JSON_VALUE)).isTrue();
|
||||
assertThat(configuration.returnBodyOnUpdate(MediaType.APPLICATION_JSON_VALUE)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAREST-34
|
||||
public void doesNotReturnBodiesIfNoAcceptHeaderPresentByDefault() {
|
||||
|
||||
assertThat(configuration.returnBodyOnCreate(null), is(false));
|
||||
assertThat(configuration.returnBodyOnUpdate(null), is(false));
|
||||
assertThat(configuration.returnBodyOnCreate(null)).isFalse();
|
||||
assertThat(configuration.returnBodyOnUpdate(null)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-34
|
||||
public void doesNotReturnBodiesIfEmptyAcceptHeaderPresentByDefault() {
|
||||
|
||||
assertThat(configuration.returnBodyOnCreate(""), is(false));
|
||||
assertThat(configuration.returnBodyOnUpdate(""), is(false));
|
||||
assertThat(configuration.returnBodyOnCreate("")).isFalse();
|
||||
assertThat(configuration.returnBodyOnUpdate("")).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-34
|
||||
@@ -77,9 +76,9 @@ public class RepositoryRestConfigurationUnitTests {
|
||||
|
||||
configuration.setReturnBodyOnUpdate(false);
|
||||
|
||||
assertThat(configuration.returnBodyOnUpdate(null), is(false));
|
||||
assertThat(configuration.returnBodyOnUpdate(""), is(false));
|
||||
assertThat(configuration.returnBodyOnUpdate(MediaType.APPLICATION_JSON_VALUE), is(false));
|
||||
assertThat(configuration.returnBodyOnUpdate(null)).isFalse();
|
||||
assertThat(configuration.returnBodyOnUpdate("")).isFalse();
|
||||
assertThat(configuration.returnBodyOnUpdate(MediaType.APPLICATION_JSON_VALUE)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-34
|
||||
@@ -87,9 +86,9 @@ public class RepositoryRestConfigurationUnitTests {
|
||||
|
||||
configuration.setReturnBodyOnCreate(false);
|
||||
|
||||
assertThat(configuration.returnBodyOnCreate(null), is(false));
|
||||
assertThat(configuration.returnBodyOnCreate(""), is(false));
|
||||
assertThat(configuration.returnBodyOnCreate(MediaType.APPLICATION_JSON_VALUE), is(false));
|
||||
assertThat(configuration.returnBodyOnCreate(null)).isFalse();
|
||||
assertThat(configuration.returnBodyOnCreate("")).isFalse();
|
||||
assertThat(configuration.returnBodyOnCreate(MediaType.APPLICATION_JSON_VALUE)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-34
|
||||
@@ -97,9 +96,9 @@ public class RepositoryRestConfigurationUnitTests {
|
||||
|
||||
configuration.setReturnBodyOnUpdate(true);
|
||||
|
||||
assertThat(configuration.returnBodyOnUpdate(null), is(true));
|
||||
assertThat(configuration.returnBodyOnUpdate(""), is(true));
|
||||
assertThat(configuration.returnBodyOnUpdate(MediaType.APPLICATION_JSON_VALUE), is(true));
|
||||
assertThat(configuration.returnBodyOnUpdate(null)).isTrue();
|
||||
assertThat(configuration.returnBodyOnUpdate("")).isTrue();
|
||||
assertThat(configuration.returnBodyOnUpdate(MediaType.APPLICATION_JSON_VALUE)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAREST-34
|
||||
@@ -107,9 +106,9 @@ public class RepositoryRestConfigurationUnitTests {
|
||||
|
||||
configuration.setReturnBodyOnCreate(true);
|
||||
|
||||
assertThat(configuration.returnBodyOnCreate(null), is(true));
|
||||
assertThat(configuration.returnBodyOnCreate(""), is(true));
|
||||
assertThat(configuration.returnBodyOnCreate(MediaType.APPLICATION_JSON_VALUE), is(true));
|
||||
assertThat(configuration.returnBodyOnCreate(null)).isTrue();
|
||||
assertThat(configuration.returnBodyOnCreate("")).isTrue();
|
||||
assertThat(configuration.returnBodyOnCreate(MediaType.APPLICATION_JSON_VALUE)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAREST-776
|
||||
@@ -117,7 +116,7 @@ public class RepositoryRestConfigurationUnitTests {
|
||||
|
||||
configuration.withEntityLookup().forLookupRepository(ProfileRepository.class);
|
||||
|
||||
assertThat(configuration.isLookupType(Profile.class), is(true));
|
||||
assertThat(configuration.isLookupType(Profile.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAREST-573
|
||||
@@ -127,9 +126,9 @@ public class RepositoryRestConfigurationUnitTests {
|
||||
registry.addMapping("/hello").maxAge(1234);
|
||||
|
||||
Map<String, CorsConfiguration> corsConfigurations = registry.getCorsConfigurations();
|
||||
assertThat(corsConfigurations, hasKey("/hello"));
|
||||
assertThat(corsConfigurations).containsKey("/hello");
|
||||
|
||||
CorsConfiguration corsConfiguration = corsConfigurations.get("/hello");
|
||||
assertThat(corsConfiguration.getMaxAge(), is(1234L));
|
||||
assertThat(corsConfiguration.getMaxAge()).isEqualTo(1234L);
|
||||
}
|
||||
}
|
||||
|
||||
32
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/UriToEntityConverterUnitTests.java
Normal file → Executable file
32
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/UriToEntityConverterUnitTests.java
Normal file → Executable file
@@ -15,20 +15,20 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.core.convert.ConversionFailedException;
|
||||
import org.springframework.core.convert.TypeDescriptor;
|
||||
import org.springframework.core.convert.converter.GenericConverter.ConvertiblePair;
|
||||
@@ -40,6 +40,7 @@ import org.springframework.data.repository.support.Repositories;
|
||||
import org.springframework.data.repository.support.RepositoryInvoker;
|
||||
import org.springframework.data.repository.support.RepositoryInvokerFactory;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
import org.springframework.data.util.Streamable;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link UriToEntityConverter}.
|
||||
@@ -56,14 +57,13 @@ public class UriToEntityConverterUnitTests {
|
||||
@Mock Repositories repositories;
|
||||
@Mock RepositoryInvokerFactory invokerFactory;
|
||||
|
||||
KeyValueMappingContext context;
|
||||
KeyValueMappingContext<?, ?> context;
|
||||
UriToEntityConverter converter;
|
||||
|
||||
@Before
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setUp() {
|
||||
|
||||
this.context = new KeyValueMappingContext();
|
||||
this.context = new KeyValueMappingContext<>();
|
||||
this.context.setInitialEntitySet(new HashSet<Class<?>>(Arrays.asList(Entity.class, NonEntity.class)));
|
||||
this.context.afterPropertiesSet();
|
||||
|
||||
@@ -76,26 +76,27 @@ public class UriToEntityConverterUnitTests {
|
||||
|
||||
Set<ConvertiblePair> result = converter.getConvertibleTypes();
|
||||
|
||||
assertThat(result, hasItem(new ConvertiblePair(URI.class, Entity.class)));
|
||||
assertThat(result, not(hasItem(new ConvertiblePair(URI.class, NonEntity.class))));
|
||||
assertThat(result).contains(new ConvertiblePair(URI.class, Entity.class));
|
||||
assertThat(result).doesNotContain(new ConvertiblePair(URI.class, NonEntity.class));
|
||||
}
|
||||
|
||||
@Test // DATAREST-427
|
||||
public void cannotConvertEntityWithIdPropertyIfStringConversionMissing() {
|
||||
assertThat(converter.matches(URI_TYPE, ENTITY_TYPE), is(false));
|
||||
assertThat(converter.matches(URI_TYPE, ENTITY_TYPE)).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-427
|
||||
public void canConvertEntityWithIdPropertyAndFromStringConversionPossible() {
|
||||
|
||||
doReturn(mock(RepositoryInformation.class)).when(repositories).getRepositoryInformationFor(ENTITY_TYPE.getType());
|
||||
doReturn(Optional.of(mock(RepositoryInformation.class))).when(repositories)
|
||||
.getRepositoryInformationFor(ENTITY_TYPE.getType());
|
||||
|
||||
assertThat(converter.matches(URI_TYPE, ENTITY_TYPE), is(true));
|
||||
assertThat(converter.matches(URI_TYPE, ENTITY_TYPE)).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAREST-427
|
||||
public void cannotConvertEntityWithoutIdentifier() {
|
||||
assertThat(converter.matches(URI_TYPE, TypeDescriptor.valueOf(NonEntity.class)), is(false));
|
||||
assertThat(converter.matches(URI_TYPE, TypeDescriptor.valueOf(NonEntity.class))).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-427
|
||||
@@ -104,10 +105,10 @@ public class UriToEntityConverterUnitTests {
|
||||
Entity reference = new Entity();
|
||||
|
||||
RepositoryInvoker invoker = mock(RepositoryInvoker.class);
|
||||
doReturn(reference).when(invoker).invokeFindOne("1");
|
||||
doReturn(Optional.of(reference)).when(invoker).invokeFindOne("1");
|
||||
doReturn(invoker).when(invokerFactory).getInvokerFor(ENTITY_TYPE.getType());
|
||||
|
||||
assertThat(converter.convert(URI.create("/foo/bar/1"), URI_TYPE, ENTITY_TYPE), is((Object) reference));
|
||||
assertThat(converter.convert(URI.create("/foo/bar/1"), URI_TYPE, ENTITY_TYPE)).isEqualTo((Object) reference);
|
||||
}
|
||||
|
||||
@Test(expected = ConversionFailedException.class) // DATAREST-427
|
||||
@@ -139,11 +140,10 @@ public class UriToEntityConverterUnitTests {
|
||||
* @see DATAREST-1018
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void doesNotRegisterTypeWithUnmanagedRawType() {
|
||||
|
||||
PersistentEntities entities = mock(PersistentEntities.class);
|
||||
doReturn(Arrays.asList(ClassTypeInformation.OBJECT)).when(entities).getManagedTypes();
|
||||
doReturn(Streamable.of(ClassTypeInformation.OBJECT)).when(entities).getManagedTypes();
|
||||
|
||||
new UriToEntityConverter(entities, invokerFactory, repositories);
|
||||
}
|
||||
|
||||
11
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/ValidationErrorsUnitTests.java
Normal file → Executable file
11
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/ValidationErrorsUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -41,7 +40,7 @@ public class ValidationErrorsUnitTests {
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
KeyValueMappingContext context = new KeyValueMappingContext();
|
||||
KeyValueMappingContext<?, ?> context = new KeyValueMappingContext<>();
|
||||
context.getPersistentEntity(Foo.class);
|
||||
|
||||
this.entities = new PersistentEntities(Arrays.asList(context));
|
||||
@@ -56,7 +55,7 @@ public class ValidationErrorsUnitTests {
|
||||
errors.rejectValue("field", "asdf");
|
||||
errors.popNestedPath();
|
||||
|
||||
assertThat(errors.getFieldError().getField(), is("bars[0].field"));
|
||||
assertThat(errors.getFieldError().getField()).isEqualTo("bars[0].field");
|
||||
}
|
||||
|
||||
@Test // DATAREST-801
|
||||
@@ -66,7 +65,7 @@ public class ValidationErrorsUnitTests {
|
||||
|
||||
private static void expectedErrorBehavior(Errors errors) {
|
||||
|
||||
assertThat(errors.getFieldValue("bars"), is(notNullValue()));
|
||||
assertThat(errors.getFieldValue("bars")).isNotNull();
|
||||
|
||||
errors.pushNestedPath("bars[0]");
|
||||
|
||||
@@ -75,7 +74,7 @@ public class ValidationErrorsUnitTests {
|
||||
fail("Expected NotReadablePropertyException!");
|
||||
} catch (NotReadablePropertyException e) {}
|
||||
|
||||
assertThat(errors.getFieldValue("field"), is((Object) "Hello"));
|
||||
assertThat(errors.getFieldValue("field")).isEqualTo((Object) "Hello");
|
||||
}
|
||||
|
||||
static class Foo {
|
||||
|
||||
38
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/config/ProjectionDefinitionConfigurationUnitTests.java
Normal file → Executable file
38
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/config/ProjectionDefinitionConfigurationUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.config;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -28,7 +27,6 @@ import org.springframework.data.rest.core.config.ProjectionDefinitionConfigurati
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class ProjectionDefinitionConfigurationUnitTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATAREST-221
|
||||
@@ -67,7 +65,7 @@ public class ProjectionDefinitionConfigurationUnitTests {
|
||||
ProjectionDefinitionConfiguration configuration = new ProjectionDefinitionConfiguration();
|
||||
configuration.addProjection(Integer.class, "name", String.class);
|
||||
|
||||
assertThat(configuration.getProjectionType(String.class, "name"), is(equalTo((Class) Integer.class)));
|
||||
assertThat(configuration.getProjectionType(String.class, "name")).isEqualTo(Integer.class);
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
@@ -76,7 +74,7 @@ public class ProjectionDefinitionConfigurationUnitTests {
|
||||
ProjectionDefinitionConfiguration configuration = new ProjectionDefinitionConfiguration();
|
||||
configuration.addProjection(SampleProjection.class);
|
||||
|
||||
assertThat(configuration.getProjectionType(Integer.class, "name"), is(equalTo((Class) SampleProjection.class)));
|
||||
assertThat(configuration.getProjectionType(Integer.class, "name")).isEqualTo(SampleProjection.class);
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
@@ -85,7 +83,7 @@ public class ProjectionDefinitionConfigurationUnitTests {
|
||||
ProjectionDefinitionConfiguration configuration = new ProjectionDefinitionConfiguration();
|
||||
configuration.addProjection(Default.class);
|
||||
|
||||
assertThat(configuration.getProjectionType(Integer.class, "default"), is(equalTo((Class) Default.class)));
|
||||
assertThat(configuration.getProjectionType(Integer.class, "default")).isEqualTo(Default.class);
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
@@ -96,17 +94,17 @@ public class ProjectionDefinitionConfigurationUnitTests {
|
||||
ProjectionDefinition stringName = ProjectionDefinition.of(String.class, Object.class, "name");
|
||||
ProjectionDefinition objectOtherNameKey = ProjectionDefinition.of(Object.class, Object.class, "otherName");
|
||||
|
||||
assertThat(objectName, is(objectName));
|
||||
assertThat(objectName, is(sameObjectName));
|
||||
assertThat(sameObjectName, is(objectName));
|
||||
assertThat(objectName).isEqualTo(objectName);
|
||||
assertThat(objectName).isEqualTo(sameObjectName);
|
||||
assertThat(sameObjectName).isEqualTo(objectName);
|
||||
|
||||
assertThat(objectName, is(not(stringName)));
|
||||
assertThat(stringName, is(not(objectName)));
|
||||
assertThat(objectName).isNotEqualTo(stringName);
|
||||
assertThat(stringName).isNotEqualTo(objectName);
|
||||
|
||||
assertThat(objectName, is(not(objectOtherNameKey)));
|
||||
assertThat(objectOtherNameKey, is(not(objectName)));
|
||||
assertThat(objectName).isNotEqualTo(objectOtherNameKey);
|
||||
assertThat(objectOtherNameKey).isNotEqualTo(objectName);
|
||||
|
||||
assertThat(objectName, is(not(new Object())));
|
||||
assertThat(objectName).isNotEqualTo(new Object());
|
||||
}
|
||||
|
||||
@Test // DATAREST-385
|
||||
@@ -115,14 +113,14 @@ public class ProjectionDefinitionConfigurationUnitTests {
|
||||
ProjectionDefinitionConfiguration configuration = new ProjectionDefinitionConfiguration();
|
||||
configuration.addProjection(ParentProjection.class);
|
||||
|
||||
assertThat(configuration.hasProjectionFor(Child.class), is(true));
|
||||
assertThat(configuration.getProjectionsFor(Child.class).values(), hasItem(ParentProjection.class));
|
||||
assertThat(configuration.getProjectionType(Child.class, "summary"), is(typeCompatibleWith(ParentProjection.class)));
|
||||
assertThat(configuration.hasProjectionFor(Child.class)).isTrue();
|
||||
assertThat(configuration.getProjectionsFor(Child.class).values()).contains(ParentProjection.class);
|
||||
assertThat(configuration.getProjectionType(Child.class, "summary")).isAssignableFrom(ParentProjection.class);
|
||||
}
|
||||
|
||||
@Test // DATAREST-221
|
||||
public void defaultsParamternameToProjection() {
|
||||
assertThat(new ProjectionDefinitionConfiguration().getParameterName(), is("projection"));
|
||||
assertThat(new ProjectionDefinitionConfiguration().getParameterName()).isEqualTo("projection");
|
||||
}
|
||||
|
||||
@Test // DATAREST-747
|
||||
@@ -134,8 +132,8 @@ public class ProjectionDefinitionConfigurationUnitTests {
|
||||
|
||||
Map<String, Class<?>> projections = configuration.getProjectionsFor(Child.class);
|
||||
|
||||
assertThat(projections.values(), hasSize(1));
|
||||
assertThat(projections.values(), hasItem(ChildProjection.class));
|
||||
assertThat(projections.values()).hasSize(1);
|
||||
assertThat(projections.values()).contains(ChildProjection.class);
|
||||
}
|
||||
|
||||
@Projection(name = "name", types = Integer.class)
|
||||
|
||||
22
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/config/ResourceMappingUnitTests.java
Normal file → Executable file
22
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/config/ResourceMappingUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.config;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.rest.core.support.ResourceMappingUtils.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -43,16 +42,17 @@ public class ResourceMappingUnitTests {
|
||||
|
||||
@Test
|
||||
public void shouldDetectPathAndRemoveLeadingSlashIfAny() {
|
||||
|
||||
org.springframework.data.rest.core.config.ResourceMapping mapping = new org.springframework.data.rest.core.config.ResourceMapping(
|
||||
findRel(AnnotatedWithLeadingSlashPersonRepository.class),
|
||||
findPath(AnnotatedWithLeadingSlashPersonRepository.class),
|
||||
findExported(AnnotatedWithLeadingSlashPersonRepository.class));
|
||||
|
||||
// The rel attribute defaults to class name
|
||||
assertThat(mapping.getRel(), is("annotatedWithLeadingSlashPerson"));
|
||||
assertThat(mapping.getPath(), is("people"));
|
||||
assertThat(mapping.getRel()).isEqualTo("annotatedWithLeadingSlashPerson");
|
||||
assertThat(mapping.getPath()).isEqualTo("people");
|
||||
// The exported defaults to true
|
||||
assertThat(mapping.isExported(), is(true));
|
||||
assertThat(mapping.isExported()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,10 +63,10 @@ public class ResourceMappingUnitTests {
|
||||
findRel(method), findPath(method), findExported(method));
|
||||
|
||||
// The rel attribute defaults to class name
|
||||
assertThat(mapping.getRel(), is("findByFirstName"));
|
||||
assertThat(mapping.getPath(), is("firstname"));
|
||||
assertThat(mapping.getRel()).isEqualTo("findByFirstName");
|
||||
assertThat(mapping.getPath()).isEqualTo("firstname");
|
||||
// The exported defaults to true
|
||||
assertThat(mapping.isExported(), is(true));
|
||||
assertThat(mapping.isExported()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -77,11 +77,11 @@ public class ResourceMappingUnitTests {
|
||||
findRel(method), findPath(method), findExported(method));
|
||||
|
||||
// The rel defaults to method name
|
||||
assertThat(mapping.getRel(), is("findByLastName"));
|
||||
assertThat(mapping.getRel()).isEqualTo("findByLastName");
|
||||
// The path contains only a leading slash therefore defaults to method name
|
||||
assertThat(mapping.getPath(), is("findByLastName"));
|
||||
assertThat(mapping.getPath()).isEqualTo("findByLastName");
|
||||
// The exported defaults to true
|
||||
assertThat(mapping.isExported(), is(true));
|
||||
assertThat(mapping.isExported()).isTrue();
|
||||
}
|
||||
|
||||
@RestResource(path = "/people")
|
||||
|
||||
0
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/context/RepositoryEventIntegrationTests.java
Normal file → Executable file
0
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/context/RepositoryEventIntegrationTests.java
Normal file → Executable file
2
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/context/ValidatorIntegrationTests.java
Normal file → Executable file
2
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/context/ValidatorIntegrationTests.java
Normal file → Executable file
@@ -60,7 +60,7 @@ public class ValidatorIntegrationTests {
|
||||
}
|
||||
|
||||
@Autowired ConfigurableApplicationContext context;
|
||||
@Autowired KeyValueMappingContext mappingContext;
|
||||
@Autowired KeyValueMappingContext<?, ?> mappingContext;
|
||||
|
||||
@Test(expected = RepositoryConstraintViolationException.class)
|
||||
public void shouldValidateLastName() throws Exception {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.domain;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
@@ -29,12 +30,12 @@ public interface OrderRepository extends CrudRepository<Order, UUID> {
|
||||
* @see org.springframework.data.repository.CrudRepository#save(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public <S extends Order> S save(S entity);
|
||||
<S extends Order> S save(S entity);
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.repository.CrudRepository#findOne(java.io.Serializable)
|
||||
*/
|
||||
@Override
|
||||
public Order findOne(UUID id);
|
||||
Optional<Order> findOne(UUID id);
|
||||
}
|
||||
|
||||
17
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/event/AnnotatedEventHandlerInvokerUnitTests.java
Normal file → Executable file
17
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/event/AnnotatedEventHandlerInvokerUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.event;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
@@ -51,7 +50,7 @@ public class AnnotatedEventHandlerInvokerUnitTests {
|
||||
MultiValueMap<Class<? extends RepositoryEvent>, EventHandlerMethod> methods = (MultiValueMap<Class<? extends RepositoryEvent>, EventHandlerMethod>) ReflectionTestUtils
|
||||
.getField(invoker, "handlerMethods");
|
||||
|
||||
assertThat(methods.get(BeforeCreateEvent.class), hasSize(1));
|
||||
assertThat(methods.get(BeforeCreateEvent.class)).hasSize(1);
|
||||
}
|
||||
|
||||
@Test // DATAREST-606
|
||||
@@ -64,7 +63,7 @@ public class AnnotatedEventHandlerInvokerUnitTests {
|
||||
|
||||
invoker.onApplicationEvent(new BeforeCreateEvent(new Person("Dave", "Matthews")));
|
||||
|
||||
assertThat(sampleHandler.wasCalled, is(true));
|
||||
assertThat(sampleHandler.wasCalled).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAREST-970
|
||||
@@ -79,10 +78,10 @@ public class AnnotatedEventHandlerInvokerUnitTests {
|
||||
|
||||
invoker.onApplicationEvent(new BeforeCreateEvent(new Person("Dave", "Matthews")));
|
||||
|
||||
assertThat(orderHandler1.wasCalled, is(true));
|
||||
assertThat(orderHandler2.wasCalled, is(true));
|
||||
assertThat(orderHandler1.wasCalled).isTrue();
|
||||
assertThat(orderHandler2.wasCalled).isTrue();
|
||||
|
||||
assertThat(orderHandler1.timestamp, is(greaterThan(orderHandler2.timestamp)));
|
||||
assertThat(orderHandler1.timestamp).isGreaterThan(orderHandler2.timestamp);
|
||||
}
|
||||
|
||||
@Test // DATAREST-983
|
||||
@@ -98,8 +97,8 @@ public class AnnotatedEventHandlerInvokerUnitTests {
|
||||
invoker.onApplicationEvent(new BeforeCreateEvent(new FirstEntity()));
|
||||
invoker.onApplicationEvent(new BeforeCreateEvent(new SecondEntity()));
|
||||
|
||||
assertThat(firstHandler.callCount, is(1));
|
||||
assertThat(secondHandler.callCount, is(1));
|
||||
assertThat(firstHandler.callCount).isEqualTo(1);
|
||||
assertThat(secondHandler.callCount).isEqualTo(1);
|
||||
}
|
||||
|
||||
@RepositoryEventHandler
|
||||
|
||||
36
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/CrudMethodsSupportedHttpMethodsUnitTests.java
Normal file → Executable file
36
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/CrudMethodsSupportedHttpMethodsUnitTests.java
Normal file → Executable file
@@ -15,17 +15,17 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.mapping;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.rest.core.mapping.ResourceType.*;
|
||||
import static org.springframework.http.HttpMethod.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.data.annotation.ReadOnlyProperty;
|
||||
import org.springframework.data.annotation.Reference;
|
||||
import org.springframework.data.keyvalue.core.mapping.KeyValuePersistentEntity;
|
||||
@@ -88,22 +88,24 @@ public class CrudMethodsSupportedHttpMethodsUnitTests {
|
||||
@Test // DATAREST-523
|
||||
public void exposesMethodsForProperties() {
|
||||
|
||||
KeyValueMappingContext context = new KeyValueMappingContext();
|
||||
KeyValuePersistentEntity<?> entity = context.getPersistentEntity(Entity.class);
|
||||
KeyValueMappingContext<?, ?> context = new KeyValueMappingContext<>();
|
||||
KeyValuePersistentEntity<?, ?> entity = context.getRequiredPersistentEntity(Entity.class);
|
||||
|
||||
SupportedHttpMethods methods = getSupportedHttpMethodsFor(EntityRepository.class);
|
||||
|
||||
assertThat(methods.getMethodsFor(entity.getPersistentProperty("embedded")), is(empty()));
|
||||
assertThat(methods.getMethodsFor(entity.getPersistentProperty("embeddedCollection")), is(empty()));
|
||||
assertThat(methods.getMethodsFor(entity.getRequiredPersistentProperty("embedded"))).isEmpty();
|
||||
assertThat(methods.getMethodsFor(entity.getRequiredPersistentProperty("embeddedCollection"))).isEmpty();
|
||||
|
||||
assertThat(methods.getMethodsFor(entity.getPersistentProperty("related")),
|
||||
allOf(hasItems(GET, DELETE, PATCH, PUT), not(hasItem(POST))));
|
||||
assertThat(methods.getMethodsFor(entity.getRequiredPersistentProperty("related")))//
|
||||
.contains(GET, DELETE, PATCH, PUT)//
|
||||
.doesNotContain(POST);
|
||||
|
||||
assertThat(methods.getMethodsFor(entity.getPersistentProperty("relatedCollection")),
|
||||
hasItems(GET, DELETE, PATCH, PUT, POST));
|
||||
assertThat(methods.getMethodsFor(entity.getRequiredPersistentProperty("relatedCollection")))//
|
||||
.contains(GET, DELETE, PATCH, PUT, POST);
|
||||
|
||||
assertThat(methods.getMethodsFor(entity.getPersistentProperty("readOnlyReference")),
|
||||
allOf(hasItem(GET), not(hasItems(DELETE, PATCH, PUT, POST))));
|
||||
assertThat(methods.getMethodsFor(entity.getRequiredPersistentProperty("readOnlyReference")))//
|
||||
.contains(GET)//
|
||||
.doesNotContain(DELETE, PATCH, PUT, POST);
|
||||
}
|
||||
|
||||
@Test // DATAREST-825
|
||||
@@ -129,10 +131,10 @@ public class CrudMethodsSupportedHttpMethodsUnitTests {
|
||||
|
||||
Set<HttpMethod> result = methods.getMethodsFor(type);
|
||||
|
||||
assertThat(result, supported ? hasItems(httpMethods) : not(hasItems(httpMethods)));
|
||||
|
||||
if (supported) {
|
||||
assertThat(result, hasSize(httpMethods.length));
|
||||
assertThat(result).containsExactlyInAnyOrder(httpMethods);
|
||||
} else {
|
||||
assertThat(result).doesNotContain(httpMethods);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +152,7 @@ public class CrudMethodsSupportedHttpMethodsUnitTests {
|
||||
|
||||
@Override
|
||||
@RestResource(exported = false)
|
||||
Object findOne(Long id);
|
||||
Optional<Object> findOne(Long id);
|
||||
}
|
||||
|
||||
interface NoFindOne extends Repository<Object, Long> {
|
||||
|
||||
23
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/MappingResourceMetadataUnitTests.java
Normal file → Executable file
23
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/MappingResourceMetadataUnitTests.java
Normal file → Executable file
@@ -15,14 +15,13 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.mapping;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.data.annotation.Reference;
|
||||
import org.springframework.data.keyvalue.core.mapping.KeyValuePersistentEntity;
|
||||
import org.springframework.data.keyvalue.core.mapping.KeyValuePersistentProperty;
|
||||
@@ -38,9 +37,9 @@ import org.springframework.data.rest.core.annotation.RestResource;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MappingResourceMetadataUnitTests {
|
||||
|
||||
KeyValueMappingContext context = new KeyValueMappingContext();
|
||||
KeyValueMappingContext<?, ?> context = new KeyValueMappingContext<>();
|
||||
|
||||
KeyValuePersistentEntity<?> entity = context.getPersistentEntity(Entity.class);
|
||||
KeyValuePersistentEntity<?, ?> entity = context.getRequiredPersistentEntity(Entity.class);
|
||||
ResourceMappings resourceMappings = new PersistentEntitiesResourceMappings(
|
||||
new PersistentEntities(Arrays.asList(context)));
|
||||
MappingResourceMetadata metadata = new MappingResourceMetadata(entity, resourceMappings);
|
||||
@@ -48,27 +47,27 @@ public class MappingResourceMetadataUnitTests {
|
||||
@Test // DATAREST-514
|
||||
public void allowsLookupOfPropertyByMappedName() {
|
||||
|
||||
KeyValuePersistentProperty property = entity.getPersistentProperty("related");
|
||||
KeyValuePersistentProperty<?> property = entity.getRequiredPersistentProperty("related");
|
||||
|
||||
PropertyAwareResourceMapping propertyMapping = metadata.getProperty("foo");
|
||||
|
||||
assertThat(propertyMapping, is(notNullValue()));
|
||||
assertThat(propertyMapping.getProperty(), is((Object) property));
|
||||
assertThat(metadata.getMappingFor(property).getPath().matches("foo"), is(true));
|
||||
assertThat(propertyMapping).isNotNull();
|
||||
assertThat(propertyMapping.getProperty()).isEqualTo((Object) property);
|
||||
assertThat(metadata.getMappingFor(property).getPath().matches("foo")).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAREST-518
|
||||
public void isNotExportedByDefault() {
|
||||
|
||||
assertThat(metadata.isExported(), is(false));
|
||||
assertThat(metadata.isExported()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-518
|
||||
public void isExportedIfExplicitlyAnnotated() {
|
||||
|
||||
MappingResourceMetadata metadata = new MappingResourceMetadata(context.getPersistentEntity(Related.class),
|
||||
MappingResourceMetadata metadata = new MappingResourceMetadata(context.getRequiredPersistentEntity(Related.class),
|
||||
resourceMappings);
|
||||
assertThat(metadata.isExported(), is(true));
|
||||
assertThat(metadata.isExported()).isTrue();
|
||||
}
|
||||
|
||||
static class Entity {
|
||||
|
||||
43
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/PersistentPropertyResourceMappingUnitTests.java
Normal file → Executable file
43
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/PersistentPropertyResourceMappingUnitTests.java
Normal file → Executable file
@@ -15,15 +15,14 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.mapping;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.data.annotation.Reference;
|
||||
import org.springframework.data.keyvalue.core.mapping.KeyValuePersistentEntity;
|
||||
import org.springframework.data.keyvalue.core.mapping.KeyValuePersistentProperty;
|
||||
@@ -41,17 +40,17 @@ import org.springframework.data.rest.core.annotation.RestResource;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class PersistentPropertyResourceMappingUnitTests {
|
||||
|
||||
KeyValueMappingContext mappingContext = new KeyValueMappingContext();
|
||||
KeyValueMappingContext<?, ?> mappingContext = new KeyValueMappingContext<>();
|
||||
|
||||
@Test // DATAREST-175
|
||||
public void usesPropertyNameAsDefaultResourceMappingRelAndPath() {
|
||||
|
||||
ResourceMapping mapping = getPropertyMappingFor(Entity.class, "first");
|
||||
|
||||
assertThat(mapping, is(notNullValue()));
|
||||
assertThat(mapping.getPath(), is(new Path("first")));
|
||||
assertThat(mapping.getRel(), is("first"));
|
||||
assertThat(mapping.isExported(), is(false));
|
||||
assertThat(mapping).isNotNull();
|
||||
assertThat(mapping.getPath()).isEqualTo(new Path("first"));
|
||||
assertThat(mapping.getRel()).isEqualTo("first");
|
||||
assertThat(mapping.isExported()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-175
|
||||
@@ -59,10 +58,10 @@ public class PersistentPropertyResourceMappingUnitTests {
|
||||
|
||||
ResourceMapping mapping = getPropertyMappingFor(Entity.class, "second");
|
||||
|
||||
assertThat(mapping, is(notNullValue()));
|
||||
assertThat(mapping.getPath(), is(new Path("secPath")));
|
||||
assertThat(mapping.getRel(), is("secRel"));
|
||||
assertThat(mapping.isExported(), is(false));
|
||||
assertThat(mapping).isNotNull();
|
||||
assertThat(mapping.getPath()).isEqualTo(new Path("secPath"));
|
||||
assertThat(mapping.getRel()).isEqualTo("secRel");
|
||||
assertThat(mapping.isExported()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-175
|
||||
@@ -70,10 +69,10 @@ public class PersistentPropertyResourceMappingUnitTests {
|
||||
|
||||
ResourceMapping mapping = getPropertyMappingFor(Entity.class, "third");
|
||||
|
||||
assertThat(mapping, is(notNullValue()));
|
||||
assertThat(mapping.getPath(), is(new Path("thirdPath")));
|
||||
assertThat(mapping.getRel(), is("thirdRel"));
|
||||
assertThat(mapping.isExported(), is(false));
|
||||
assertThat(mapping).isNotNull();
|
||||
assertThat(mapping.getPath()).isEqualTo(new Path("thirdPath"));
|
||||
assertThat(mapping.getRel()).isEqualTo("thirdRel");
|
||||
assertThat(mapping.isExported()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-233
|
||||
@@ -83,8 +82,8 @@ public class PersistentPropertyResourceMappingUnitTests {
|
||||
|
||||
ResourceDescription description = mapping.getDescription();
|
||||
|
||||
assertThat(description.isDefault(), is(true));
|
||||
assertThat(description.getMessage(), is("rest.description.entity.second"));
|
||||
assertThat(description.isDefault()).isTrue();
|
||||
assertThat(description.getMessage()).isEqualTo("rest.description.entity.second");
|
||||
}
|
||||
|
||||
@Test // DATAREST-233
|
||||
@@ -93,14 +92,14 @@ public class PersistentPropertyResourceMappingUnitTests {
|
||||
ResourceMapping mapping = getPropertyMappingFor(Entity.class, "fourth");
|
||||
|
||||
ResourceDescription description = mapping.getDescription();
|
||||
assertThat(description.isDefault(), is(false));
|
||||
assertThat(description.getMessage(), is("Some description"));
|
||||
assertThat(description.isDefault()).isFalse();
|
||||
assertThat(description.getMessage()).isEqualTo("Some description");
|
||||
}
|
||||
|
||||
private ResourceMapping getPropertyMappingFor(Class<?> entity, String propertyName) {
|
||||
|
||||
KeyValuePersistentEntity<?> persistentEntity = mappingContext.getPersistentEntity(entity);
|
||||
KeyValuePersistentProperty property = persistentEntity.getPersistentProperty(propertyName);
|
||||
KeyValuePersistentEntity<?, ?> persistentEntity = mappingContext.getRequiredPersistentEntity(entity);
|
||||
KeyValuePersistentProperty<?> property = persistentEntity.getRequiredPersistentProperty(propertyName);
|
||||
|
||||
ResourceMappings resourceMappings = new PersistentEntitiesResourceMappings(
|
||||
new PersistentEntities(Arrays.asList(mappingContext)));
|
||||
|
||||
37
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/RepositoryCollectionResourceMappingUnitTests.java
Normal file → Executable file
37
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/RepositoryCollectionResourceMappingUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.mapping;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -41,10 +40,10 @@ public class RepositoryCollectionResourceMappingUnitTests {
|
||||
|
||||
CollectionResourceMapping mapping = getResourceMappingFor(PersonRepository.class);
|
||||
|
||||
assertThat(mapping.getPath(), is(new Path("persons")));
|
||||
assertThat(mapping.getRel(), is("persons"));
|
||||
assertThat(mapping.getItemResourceRel(), is("person"));
|
||||
assertThat(mapping.isExported(), is(true));
|
||||
assertThat(mapping.getPath()).isEqualTo(new Path("persons"));
|
||||
assertThat(mapping.getRel()).isEqualTo("persons");
|
||||
assertThat(mapping.getItemResourceRel()).isEqualTo("person");
|
||||
assertThat(mapping.isExported()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -52,10 +51,10 @@ public class RepositoryCollectionResourceMappingUnitTests {
|
||||
|
||||
CollectionResourceMapping mapping = getResourceMappingFor(AnnotatedPersonRepository.class);
|
||||
|
||||
assertThat(mapping.getPath(), is(new Path("bar")));
|
||||
assertThat(mapping.getRel(), is("foo"));
|
||||
assertThat(mapping.getItemResourceRel(), is("annotatedPerson"));
|
||||
assertThat(mapping.isExported(), is(false));
|
||||
assertThat(mapping.getPath()).isEqualTo(new Path("bar"));
|
||||
assertThat(mapping.getRel()).isEqualTo("foo");
|
||||
assertThat(mapping.getItemResourceRel()).isEqualTo("annotatedPerson");
|
||||
assertThat(mapping.isExported()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,30 +62,30 @@ public class RepositoryCollectionResourceMappingUnitTests {
|
||||
|
||||
CollectionResourceMapping mapping = getResourceMappingFor(AnnotatedAnnotatedPersonRepository.class);
|
||||
|
||||
assertThat(mapping.getPath(), is(new Path("/trumpsAll")));
|
||||
assertThat(mapping.getRel(), is("foo"));
|
||||
assertThat(mapping.getItemResourceRel(), is("annotatedPerson"));
|
||||
assertThat(mapping.isExported(), is(true));
|
||||
assertThat(mapping.getPath()).isEqualTo(new Path("/trumpsAll"));
|
||||
assertThat(mapping.getRel()).isEqualTo("foo");
|
||||
assertThat(mapping.getItemResourceRel()).isEqualTo("annotatedPerson");
|
||||
assertThat(mapping.isExported()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doesNotExposeRepositoryForPublicDomainTypeIfRepoIsPackageProtected() {
|
||||
|
||||
ResourceMapping mapping = getResourceMappingFor(PackageProtectedRepository.class);
|
||||
assertThat(mapping.isExported(), is(false));
|
||||
assertThat(mapping.isExported()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-229
|
||||
public void detectsPagingRepository() {
|
||||
assertThat(getResourceMappingFor(PersonRepository.class).isPagingResource(), is(true));
|
||||
assertThat(getResourceMappingFor(PersonRepository.class).isPagingResource()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void discoversCustomizationsUsingRestRepositoryResource() {
|
||||
|
||||
CollectionResourceMapping mapping = getResourceMappingFor(RepositoryAnnotatedRepository.class);
|
||||
assertThat(mapping.getRel(), is("foo"));
|
||||
assertThat(mapping.getItemResourceRel(), is("bar"));
|
||||
assertThat(mapping.getRel()).isEqualTo("foo");
|
||||
assertThat(mapping.getItemResourceRel()).isEqualTo("bar");
|
||||
}
|
||||
|
||||
@Test // DATAREST-445
|
||||
@@ -103,7 +102,7 @@ public class RepositoryCollectionResourceMappingUnitTests {
|
||||
RepositoryCollectionResourceMapping mapping = new RepositoryCollectionResourceMapping(metadata,
|
||||
RepositoryDetectionStrategies.DEFAULT);
|
||||
|
||||
assertThat(mapping.getPath(), is(new Path("/objects")));
|
||||
assertThat(mapping.getPath()).isEqualTo(new Path("/objects"));
|
||||
}
|
||||
|
||||
private static CollectionResourceMapping getResourceMappingFor(Class<?> repositoryInterface) {
|
||||
|
||||
5
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/RepositoryDetectionStrategiesUnitTests.java
Normal file → Executable file
5
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/RepositoryDetectionStrategiesUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.mapping;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.rest.core.mapping.RepositoryDetectionStrategy.RepositoryDetectionStrategies.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -93,7 +92,7 @@ public class RepositoryDetectionStrategiesUnitTests {
|
||||
private static void assertExposures(RepositoryDetectionStrategy strategy, Map<Class<?>, Boolean> expected) {
|
||||
|
||||
for (Entry<Class<?>, Boolean> entry : expected.entrySet()) {
|
||||
assertThat(strategy.isExported(new DefaultRepositoryMetadata(entry.getKey())), is(entry.getValue()));
|
||||
assertThat(strategy.isExported(new DefaultRepositoryMetadata(entry.getKey()))).isEqualTo(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
27
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/RepositoryMethodResourceMappingUnitTests.java
Normal file → Executable file
27
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/RepositoryMethodResourceMappingUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.mapping;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
@@ -49,7 +48,7 @@ public class RepositoryMethodResourceMappingUnitTests {
|
||||
Method method = PersonRepository.class.getMethod("findByLastname", String.class);
|
||||
ResourceMapping mapping = getMappingFor(method);
|
||||
|
||||
assertThat(mapping.getPath(), is(new Path("findByLastname")));
|
||||
assertThat(mapping.getPath()).isEqualTo(new Path("findByLastname"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -58,16 +57,16 @@ public class RepositoryMethodResourceMappingUnitTests {
|
||||
Method method = PersonRepository.class.getMethod("findByFirstname", String.class);
|
||||
ResourceMapping mapping = getMappingFor(method);
|
||||
|
||||
assertThat(mapping.getPath(), is(new Path("bar")));
|
||||
assertThat(mapping.getPath()).isEqualTo(new Path("bar"));
|
||||
}
|
||||
|
||||
@Test // DATAREST-31
|
||||
public void doesNotDiscoverAnyParametersIfNotAnnotated() throws Exception {
|
||||
public void discoversParametersIfCompiledWithCorrespondingFlag() throws Exception {
|
||||
|
||||
Method method = PersonRepository.class.getMethod("findByLastname", String.class);
|
||||
MethodResourceMapping mapping = getMappingFor(method);
|
||||
|
||||
assertThat(mapping.getParametersMetadata().getParameterNames(), is(emptyIterable()));
|
||||
assertThat(mapping.getParametersMetadata().getParameterNames()).contains("lastname");
|
||||
}
|
||||
|
||||
@Test // DATAREST-31
|
||||
@@ -76,8 +75,8 @@ public class RepositoryMethodResourceMappingUnitTests {
|
||||
Method method = PersonRepository.class.getMethod("findByFirstname", String.class);
|
||||
MethodResourceMapping mapping = getMappingFor(method);
|
||||
|
||||
assertThat(mapping.getParametersMetadata().getParameterNames(), hasSize(1));
|
||||
assertThat(mapping.getParametersMetadata().getParameterNames(), hasItem("firstname"));
|
||||
assertThat(mapping.getParametersMetadata().getParameterNames()).hasSize(1);
|
||||
assertThat(mapping.getParametersMetadata().getParameterNames()).contains("firstname");
|
||||
}
|
||||
|
||||
@Test // DATAREST-229
|
||||
@@ -86,7 +85,7 @@ public class RepositoryMethodResourceMappingUnitTests {
|
||||
Method method = PersonRepository.class.getMethod("findByEmailAddress", String.class, Pageable.class);
|
||||
MethodResourceMapping mapping = getMappingFor(method);
|
||||
|
||||
assertThat(mapping.isPagingResource(), is(true));
|
||||
assertThat(mapping.isPagingResource()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,7 +94,7 @@ public class RepositoryMethodResourceMappingUnitTests {
|
||||
Method method = PersonRepository.class.getMethod("findByEmailAddress", String.class, Pageable.class);
|
||||
MethodResourceMapping mapping = getMappingFor(method);
|
||||
|
||||
assertThat(mapping.getRel(), is("findByEmailAddress"));
|
||||
assertThat(mapping.getRel()).isEqualTo("findByEmailAddress");
|
||||
}
|
||||
|
||||
@Test // DATAREST-384
|
||||
@@ -104,12 +103,12 @@ public class RepositoryMethodResourceMappingUnitTests {
|
||||
Method method = PersonRepository.class.getMethod("findByEmailAddress", String.class, Sort.class);
|
||||
RepositoryMethodResourceMapping mapping = getMappingFor(method);
|
||||
|
||||
assertThat(mapping.isSortableResource(), is(true));
|
||||
assertThat(mapping.isSortableResource()).isTrue();
|
||||
|
||||
method = PersonRepository.class.getMethod("findByEmailAddress", String.class, Pageable.class);
|
||||
mapping = getMappingFor(method);
|
||||
|
||||
assertThat(mapping.isSortableResource(), is(false));
|
||||
assertThat(mapping.isSortableResource()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-467
|
||||
@@ -119,7 +118,7 @@ public class RepositoryMethodResourceMappingUnitTests {
|
||||
Method method = PersonRepository.class.getMethod("findByLastname", String.class);
|
||||
MethodResourceMapping mapping = getMappingFor(method);
|
||||
|
||||
assertThat(mapping.getReturnedDomainType(), is(equalTo((Class) Person.class)));
|
||||
assertThat(mapping.getReturnedDomainType()).isEqualTo((Class) Person.class);
|
||||
}
|
||||
|
||||
@Test // DATAREST-699
|
||||
@@ -128,7 +127,7 @@ public class RepositoryMethodResourceMappingUnitTests {
|
||||
Method method = PersonRepository.class.getMethod("findByLastname", String.class, Pageable.class);
|
||||
RepositoryMethodResourceMapping mapping = getMappingFor(method);
|
||||
|
||||
assertThat(mapping.getParametersMetadata().getParameterNames(), not(hasItem("pageable")));
|
||||
assertThat(mapping.getParametersMetadata().getParameterNames()).doesNotContain("pageable");
|
||||
}
|
||||
|
||||
private RepositoryMethodResourceMapping getMappingFor(Method method) {
|
||||
|
||||
57
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/RepositoryResourceMappingsIntegrationTests.java
Normal file → Executable file
57
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/RepositoryResourceMappingsIntegrationTests.java
Normal file → Executable file
@@ -15,14 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.mapping;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -38,6 +36,7 @@ import org.springframework.data.rest.core.domain.Author;
|
||||
import org.springframework.data.rest.core.domain.CreditCard;
|
||||
import org.springframework.data.rest.core.domain.JpaRepositoryConfig;
|
||||
import org.springframework.data.rest.core.domain.Person;
|
||||
import org.springframework.data.rest.core.domain.Profile;
|
||||
import org.springframework.data.rest.core.mapping.RepositoryDetectionStrategy.RepositoryDetectionStrategies;
|
||||
import org.springframework.hateoas.core.EvoInflectorRelProvider;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -54,13 +53,15 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
public class RepositoryResourceMappingsIntegrationTests {
|
||||
|
||||
@Autowired ListableBeanFactory factory;
|
||||
@Autowired KeyValueMappingContext mappingContext;
|
||||
@Autowired KeyValueMappingContext<?, ?> mappingContext;
|
||||
|
||||
ResourceMappings mappings;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
mappingContext.getPersistentEntity(Profile.class);
|
||||
|
||||
Repositories repositories = new Repositories(factory);
|
||||
this.mappings = new RepositoryResourceMappings(repositories, new PersistentEntities(Arrays.asList(mappingContext)),
|
||||
new EvoInflectorRelProvider(), RepositoryDetectionStrategies.DEFAULT);
|
||||
@@ -68,7 +69,7 @@ public class RepositoryResourceMappingsIntegrationTests {
|
||||
|
||||
@Test
|
||||
public void detectsAllMappings() {
|
||||
assertThat(mappings, is(Matchers.<ResourceMetadata> iterableWithSize(5)));
|
||||
assertThat(mappings).hasSize(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -76,8 +77,8 @@ public class RepositoryResourceMappingsIntegrationTests {
|
||||
|
||||
ResourceMetadata personMappings = mappings.getMetadataFor(Person.class);
|
||||
|
||||
assertThat(personMappings.isExported(), is(true));
|
||||
assertThat(personMappings.getSearchResourceMappings().isExported(), is(true));
|
||||
assertThat(personMappings.isExported()).isTrue();
|
||||
assertThat(personMappings.getSearchResourceMappings().isExported()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -85,8 +86,8 @@ public class RepositoryResourceMappingsIntegrationTests {
|
||||
|
||||
ResourceMetadata creditCardMapping = mappings.getMetadataFor(CreditCard.class);
|
||||
|
||||
assertThat(creditCardMapping.isExported(), is(false));
|
||||
assertThat(creditCardMapping.getSearchResourceMappings().isExported(), is(false));
|
||||
assertThat(creditCardMapping.isExported()).isFalse();
|
||||
assertThat(creditCardMapping.getSearchResourceMappings().isExported()).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-112
|
||||
@@ -94,27 +95,27 @@ public class RepositoryResourceMappingsIntegrationTests {
|
||||
|
||||
Repositories repositories = new Repositories(factory);
|
||||
PersistentEntity<?, ?> entity = repositories.getPersistentEntity(Person.class);
|
||||
PersistentProperty<?> property = entity.getPersistentProperty("siblings");
|
||||
PersistentProperty<?> property = entity.getRequiredPersistentProperty("siblings");
|
||||
|
||||
ResourceMetadata metadata = mappings.getMetadataFor(Person.class);
|
||||
ResourceMapping mapping = metadata.getMappingFor(property);
|
||||
|
||||
assertThat(mapping.getRel(), is("siblings"));
|
||||
assertThat(mapping.getPath(), is(new Path("siblings")));
|
||||
assertThat(mapping.isExported(), is(true));
|
||||
assertThat(mapping.getRel()).isEqualTo("siblings");
|
||||
assertThat(mapping.getPath()).isEqualTo(new Path("siblings"));
|
||||
assertThat(mapping.isExported()).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAREST-111
|
||||
public void exposesResourceByPath() {
|
||||
|
||||
assertThat(mappings.exportsTopLevelResourceFor("people"), is(true));
|
||||
assertThat(mappings.exportsTopLevelResourceFor("orders"), is(true));
|
||||
assertThat(mappings.exportsTopLevelResourceFor("people")).isTrue();
|
||||
assertThat(mappings.exportsTopLevelResourceFor("orders")).isTrue();
|
||||
|
||||
ResourceMetadata creditCardMapping = mappings.getMetadataFor(CreditCard.class);
|
||||
assertThat(creditCardMapping, is(notNullValue()));
|
||||
assertThat(creditCardMapping.getPath(), is(new Path("creditCards")));
|
||||
assertThat(creditCardMapping.isExported(), is(false));
|
||||
assertThat(mappings.exportsTopLevelResourceFor("creditCards"), is(false));
|
||||
assertThat(creditCardMapping).isNotNull();
|
||||
assertThat(creditCardMapping.getPath()).isEqualTo(new Path("creditCards"));
|
||||
assertThat(creditCardMapping.isExported()).isFalse();
|
||||
assertThat(mappings.exportsTopLevelResourceFor("creditCards")).isFalse();
|
||||
}
|
||||
|
||||
@Test // DATAREST-107
|
||||
@@ -123,7 +124,7 @@ public class RepositoryResourceMappingsIntegrationTests {
|
||||
ResourceMetadata creditCardMetadata = mappings.getMetadataFor(CreditCard.class);
|
||||
SearchResourceMappings searchResourceMappings = creditCardMetadata.getSearchResourceMappings();
|
||||
|
||||
assertThat(searchResourceMappings, is(Matchers.<MethodResourceMapping> iterableWithSize(0)));
|
||||
assertThat(searchResourceMappings).isEmpty();
|
||||
|
||||
ResourceMetadata personMetadata = mappings.getMetadataFor(Person.class);
|
||||
List<String> methodNames = new ArrayList<String>();
|
||||
@@ -132,25 +133,25 @@ public class RepositoryResourceMappingsIntegrationTests {
|
||||
methodNames.add(method.getMethod().getName());
|
||||
}
|
||||
|
||||
assertThat(methodNames, hasSize(2));
|
||||
assertThat(methodNames, hasItems("findByFirstName", "findByCreatedGreaterThan"));
|
||||
assertThat(methodNames).hasSize(2);
|
||||
assertThat(methodNames).contains("findByFirstName", "findByCreatedGreaterThan");
|
||||
}
|
||||
|
||||
@Test // DATAREST-325
|
||||
public void exposesMethodResourceMappingInPackageProtectedButExportedRepo() {
|
||||
|
||||
ResourceMetadata metadata = mappings.getMetadataFor(Author.class);
|
||||
assertThat(metadata.isExported(), is(true));
|
||||
assertThat(metadata.isExported()).isTrue();
|
||||
|
||||
SearchResourceMappings searchMappings = metadata.getSearchResourceMappings();
|
||||
|
||||
assertThat(searchMappings.isExported(), is(true));
|
||||
assertThat(searchMappings.getMappedMethod("findByFirstnameContaining"), is(notNullValue()));
|
||||
assertThat(searchMappings.isExported()).isTrue();
|
||||
assertThat(searchMappings.getMappedMethod("findByFirstnameContaining")).isNotNull();
|
||||
|
||||
for (MethodResourceMapping methodMapping : searchMappings) {
|
||||
|
||||
System.out.println(methodMapping.getMethod().getName());
|
||||
assertThat(methodMapping.isExported(), is(true));
|
||||
assertThat(methodMapping.isExported()).isTrue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +162,7 @@ public class RepositoryResourceMappingsIntegrationTests {
|
||||
|
||||
PropertyAwareResourceMapping propertyMapping = metadata.getProperty("father-mapped");
|
||||
|
||||
assertThat(propertyMapping.getRel(), is("father"));
|
||||
assertThat(propertyMapping.getPath(), is(new Path("father-mapped")));
|
||||
assertThat(propertyMapping.getRel()).isEqualTo("father");
|
||||
assertThat(propertyMapping.getPath()).isEqualTo(new Path("father-mapped"));
|
||||
}
|
||||
}
|
||||
|
||||
29
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/TypeBasedCollectionResourceMappingUnitTests.java
Normal file → Executable file
29
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/mapping/TypeBasedCollectionResourceMappingUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.mapping;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.rest.core.Path;
|
||||
@@ -34,10 +33,10 @@ public class TypeBasedCollectionResourceMappingUnitTests {
|
||||
|
||||
CollectionResourceMapping mapping = new TypeBasedCollectionResourceMapping(Sample.class);
|
||||
|
||||
assertThat(mapping.getPath(), is(new Path("sample")));
|
||||
assertThat(mapping.getRel(), is("samples"));
|
||||
assertThat(mapping.getItemResourceRel(), is("sample"));
|
||||
assertThat(mapping.isExported(), is(true));
|
||||
assertThat(mapping.getPath()).isEqualTo(new Path("sample"));
|
||||
assertThat(mapping.getRel()).isEqualTo("samples");
|
||||
assertThat(mapping.getItemResourceRel()).isEqualTo("sample");
|
||||
assertThat(mapping.isExported()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -45,10 +44,10 @@ public class TypeBasedCollectionResourceMappingUnitTests {
|
||||
|
||||
CollectionResourceMapping mapping = new TypeBasedCollectionResourceMapping(CustomizedSample.class);
|
||||
|
||||
assertThat(mapping.getPath(), is(new Path("customizedSample")));
|
||||
assertThat(mapping.getRel(), is("myRel"));
|
||||
assertThat(mapping.getItemResourceRel(), is("customizedSample"));
|
||||
assertThat(mapping.isExported(), is(true));
|
||||
assertThat(mapping.getPath()).isEqualTo(new Path("customizedSample"));
|
||||
assertThat(mapping.getRel()).isEqualTo("myRel");
|
||||
assertThat(mapping.getItemResourceRel()).isEqualTo("customizedSample");
|
||||
assertThat(mapping.isExported()).isTrue();
|
||||
}
|
||||
|
||||
@Test // DATAREST-99
|
||||
@@ -56,7 +55,7 @@ public class TypeBasedCollectionResourceMappingUnitTests {
|
||||
|
||||
CollectionResourceMapping mapping = new TypeBasedCollectionResourceMapping(HiddenSample.class);
|
||||
|
||||
assertThat(mapping.isExported(), is(false));
|
||||
assertThat(mapping.isExported()).isFalse();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,13 +67,13 @@ public class TypeBasedCollectionResourceMappingUnitTests {
|
||||
CollectionResourceMapping mapping = new TypeBasedCollectionResourceMapping(Sample.class);
|
||||
ResourceDescription description = mapping.getDescription();
|
||||
|
||||
assertThat(description.isDefault(), is(true));
|
||||
assertThat(description.getMessage(), is("rest.description.samples"));
|
||||
assertThat(description.isDefault()).isTrue();
|
||||
assertThat(description.getMessage()).isEqualTo("rest.description.samples");
|
||||
|
||||
ResourceDescription itemDescription = mapping.getItemResourceDescription();
|
||||
|
||||
assertThat(itemDescription.isDefault(), is(true));
|
||||
assertThat(itemDescription.getMessage(), is("rest.description.sample"));
|
||||
assertThat(itemDescription.isDefault()).isTrue();
|
||||
assertThat(itemDescription.getMessage()).isEqualTo("rest.description.sample");
|
||||
}
|
||||
|
||||
public interface Sample {}
|
||||
|
||||
22
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/DefaultSelfLinkProviderUnitTests.java
Normal file → Executable file
22
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/DefaultSelfLinkProviderUnitTests.java
Normal file → Executable file
@@ -16,7 +16,7 @@
|
||||
package org.springframework.data.rest.core.support;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -31,9 +31,7 @@ import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import org.springframework.data.keyvalue.core.mapping.context.KeyValueMappingContext;
|
||||
import org.springframework.data.mapping.context.PersistentEntities;
|
||||
import org.springframework.data.rest.core.domain.Profile;
|
||||
@@ -60,19 +58,15 @@ public class DefaultSelfLinkProviderUnitTests {
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
when(entityLinks.linkToSingleResource((Class<?>) any(), any())).then(new Answer<Link>() {
|
||||
when(entityLinks.linkToSingleResource((Class<?>) any(), any())).then(invocation -> {
|
||||
|
||||
@Override
|
||||
public Link answer(InvocationOnMock invocation) throws Throwable {
|
||||
Class<?> type = invocation.getArgument(0);
|
||||
Serializable id = invocation.getArgument(1);
|
||||
|
||||
Class<?> type = invocation.getArgumentAt(0, Class.class);
|
||||
Serializable id = invocation.getArgumentAt(1, Serializable.class);
|
||||
|
||||
return new Link("/".concat(type.getName()).concat("/").concat(id.toString()));
|
||||
}
|
||||
return new Link("/".concat(type.getName()).concat("/").concat(id.toString()));
|
||||
});
|
||||
|
||||
KeyValueMappingContext context = new KeyValueMappingContext();
|
||||
KeyValueMappingContext<?, ?> context = new KeyValueMappingContext<>();
|
||||
context.getPersistentEntity(Profile.class);
|
||||
context.afterPropertiesSet();
|
||||
|
||||
@@ -125,7 +119,7 @@ public class DefaultSelfLinkProviderUnitTests {
|
||||
|
||||
exception.expect(IllegalArgumentException.class);
|
||||
exception.expectMessage(Object.class.getName());
|
||||
exception.expectMessage("No persistent entity found!");
|
||||
exception.expectMessage("Couldn't find PersistentEntity for");
|
||||
|
||||
provider.createSelfLinkFor(new Object());
|
||||
}
|
||||
|
||||
13
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/DomainObjectMergerTests.java
Normal file → Executable file
13
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/DomainObjectMergerTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.support;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.rest.core.support.DomainObjectMerger.NullHandlingPolicy.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -60,8 +59,8 @@ public class DomainObjectMergerTests {
|
||||
|
||||
merger.merge(incoming, existingDomainObject, APPLY_NULLS);
|
||||
|
||||
assertThat(existingDomainObject.getFirstName(), is(incoming.getFirstName()));
|
||||
assertThat(existingDomainObject.getLastName(), is(incoming.getLastName()));
|
||||
assertThat(existingDomainObject.getFirstName()).isEqualTo(incoming.getFirstName());
|
||||
assertThat(existingDomainObject.getLastName()).isEqualTo(incoming.getLastName());
|
||||
}
|
||||
|
||||
@Test // DATAREST-130
|
||||
@@ -72,8 +71,8 @@ public class DomainObjectMergerTests {
|
||||
|
||||
merger.merge(incoming, existingDomainObject, APPLY_NULLS);
|
||||
|
||||
assertThat(existingDomainObject.getFirstName(), is(incoming.getFirstName()));
|
||||
assertThat(existingDomainObject.getLastName(), is(incoming.getLastName()));
|
||||
assertThat(existingDomainObject.getFirstName()).isEqualTo(incoming.getFirstName());
|
||||
assertThat(existingDomainObject.getLastName()).isEqualTo(incoming.getLastName());
|
||||
}
|
||||
|
||||
@Test // DATAREST-327
|
||||
@@ -86,6 +85,6 @@ public class DomainObjectMergerTests {
|
||||
|
||||
merger.merge(new Person("Sam", null), frodo, IGNORE_NULLS);
|
||||
|
||||
assertThat(frodo.getSiblings(), is(not(emptyIterable())));
|
||||
assertThat(frodo.getSiblings()).isNotEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
22
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/DomainObjectMergerUnitTests.java
Normal file → Executable file
22
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/DomainObjectMergerUnitTests.java
Normal file → Executable file
@@ -15,12 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.support;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.rest.core.support.DomainObjectMerger.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -34,16 +34,16 @@ public class DomainObjectMergerUnitTests {
|
||||
@Test // DATAREST-327
|
||||
public void considersEmptyObjectsEmpty() {
|
||||
|
||||
assertThat(isNullOrEmpty(null), is(true));
|
||||
assertThat(isNullOrEmpty(Collections.emptyList()), is(true));
|
||||
assertThat(isNullOrEmpty(new Object[0]), is(true));
|
||||
assertThat(isNullOrEmpty(new String[0]), is(true));
|
||||
assertThat(isNullOrEmpty(new MyIterable()), is(true));
|
||||
assertThat(isNullOrEmpty(Optional.empty())).isTrue();
|
||||
assertThat(isNullOrEmpty(Optional.of(Collections.emptyList()))).isTrue();
|
||||
assertThat(isNullOrEmpty(Optional.of(new Object[0]))).isTrue();
|
||||
assertThat(isNullOrEmpty(Optional.of(new String[0]))).isTrue();
|
||||
assertThat(isNullOrEmpty(Optional.of(new MyIterable()))).isTrue();
|
||||
|
||||
assertThat(isNullOrEmpty(new Object()), is(false));
|
||||
assertThat(isNullOrEmpty(Collections.singleton(new Object())), is(false));
|
||||
assertThat(isNullOrEmpty(new Object[] { "1" }), is(false));
|
||||
assertThat(isNullOrEmpty(new String[] { "1" }), is(false));
|
||||
assertThat(isNullOrEmpty(Optional.of(new Object()))).isFalse();
|
||||
assertThat(isNullOrEmpty(Optional.of(Collections.singleton(new Object())))).isFalse();
|
||||
assertThat(isNullOrEmpty(Optional.of(new Object[] { "1" }))).isFalse();
|
||||
assertThat(isNullOrEmpty(Optional.of(new String[] { "1" }))).isFalse();
|
||||
}
|
||||
|
||||
class MyIterable implements Iterable<Object> {
|
||||
|
||||
30
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/ResourceStringUtilsTests.java
Normal file → Executable file
30
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/ResourceStringUtilsTests.java
Normal file → Executable file
@@ -15,17 +15,15 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.support;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.springframework.data.rest.core.support.ResourceStringUtils;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.runners.Parameterized.Parameters;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
/**
|
||||
* Ensures proper detection and removal of leading slash in strings.
|
||||
@@ -48,23 +46,25 @@ public class ResourceStringUtilsTests {
|
||||
|
||||
@Parameters(name = "{0}")
|
||||
public static Collection<?> parameters() {
|
||||
return Arrays.asList(new Object[][] {
|
||||
{ "empty string has no text and should remain empty", "", "", false },
|
||||
{ "blank string has no text and should remain as is", " ", " ", false },
|
||||
{ "string made of only a leading slash has no text and should be returned empty", "/", "", false },
|
||||
{ "blank string with only slashes has no text and should be returned as is", " / ", " / ", false },
|
||||
{ "normal string has text and should be returned as such", "hello", "hello", true },
|
||||
{ "normal string with leading slash has text and should be returned without leading slash", "/hello", "hello",
|
||||
true }, });
|
||||
return Arrays
|
||||
.asList(
|
||||
new Object[][] { { "empty string has no text and should remain empty", "", "", false },
|
||||
{ "blank string has no text and should remain as is", " ", " ", false },
|
||||
{ "string made of only a leading slash has no text and should be returned empty", "/", "", false },
|
||||
{ "blank string with only slashes has no text and should be returned as is", " / ", " / ",
|
||||
false },
|
||||
{ "normal string has text and should be returned as such", "hello", "hello", true },
|
||||
{ "normal string with leading slash has text and should be returned without leading slash", "/hello",
|
||||
"hello", true }, });
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDetectTextPresence() {
|
||||
assertThat(ResourceStringUtils.hasTextExceptSlash(actual), is(hasText));
|
||||
assertThat(ResourceStringUtils.hasTextExceptSlash(actual)).isEqualTo(hasText);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRemoveLeadingSlashIfAny() {
|
||||
assertThat(ResourceStringUtils.removeLeadingSlash(actual), is(expected));
|
||||
assertThat(ResourceStringUtils.removeLeadingSlash(actual)).isEqualTo(expected);
|
||||
}
|
||||
}
|
||||
|
||||
47
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/UnwrappingRepositoryInvokerFactoryUnitTests.java
Normal file → Executable file
47
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/support/UnwrappingRepositoryInvokerFactoryUnitTests.java
Normal file → Executable file
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.support;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Matchers.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@@ -25,8 +23,9 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hamcrest.Matcher;
|
||||
import org.assertj.core.api.AbstractOptionalAssert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -36,7 +35,6 @@ import org.junit.runners.Parameterized.Parameters;
|
||||
import org.springframework.data.repository.support.RepositoryInvoker;
|
||||
import org.springframework.data.repository.support.RepositoryInvokerFactory;
|
||||
import org.springframework.data.rest.core.domain.Profile;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link UnwrappingRepositoryInvokerFactory}.
|
||||
@@ -54,8 +52,8 @@ public class UnwrappingRepositoryInvokerFactoryUnitTests {
|
||||
RepositoryInvokerFactory factory;
|
||||
Method method;
|
||||
|
||||
public @Parameter(value = 0) Object source;
|
||||
public @Parameter(value = 1) Matcher<Object> value;
|
||||
public @Parameter(0) Object source;
|
||||
public @Parameter(1) Consumer<AbstractOptionalAssert<?, Object>> value;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@@ -68,31 +66,23 @@ public class UnwrappingRepositoryInvokerFactoryUnitTests {
|
||||
|
||||
@Parameters
|
||||
public static Collection<Object[]> data() {
|
||||
|
||||
return Arrays.asList(new Object[][] { //
|
||||
{ Optional.empty(), is(nullValue()) }, //
|
||||
{ Optional.of(REFERENCE), is(REFERENCE) }, //
|
||||
{ com.google.common.base.Optional.absent(), is(nullValue()) }, //
|
||||
{ com.google.common.base.Optional.of(REFERENCE), is(REFERENCE) } //
|
||||
{ null, $(it -> it.isEmpty()) }, //
|
||||
{ Optional.empty(), $(it -> it.isEmpty()) }, //
|
||||
{ Optional.of(REFERENCE), $(it -> it.hasValue(REFERENCE)) }, //
|
||||
{ com.google.common.base.Optional.absent(), $(it -> it.isEmpty()) }, //
|
||||
{ com.google.common.base.Optional.of(REFERENCE), $(it -> it.hasValue(REFERENCE)) } //
|
||||
});
|
||||
}
|
||||
|
||||
@Test // DATAREST-511
|
||||
public void unwrapsValuesForFindOne() {
|
||||
assertFindOneValueForSource(source, value);
|
||||
}
|
||||
|
||||
@Test // DATAREST-511
|
||||
public void unwrapsValuesForQuery() {
|
||||
assertQueryValueForSource(source, value);
|
||||
}
|
||||
|
||||
@Test // DATAREST-724
|
||||
@SuppressWarnings("unchecked")
|
||||
public void usesRegisteredEntityLookup() {
|
||||
|
||||
EntityLookup<Object> lookup = mock(EntityLookup.class);
|
||||
when(lookup.supports(Profile.class)).thenReturn(true);
|
||||
|
||||
when(lookup.supports(Profile.class)).thenReturn(true);
|
||||
when(delegate.getInvokerFor(Profile.class)).thenReturn(invoker);
|
||||
|
||||
factory = new UnwrappingRepositoryInvokerFactory(delegate, Arrays.asList(lookup));
|
||||
@@ -101,16 +91,7 @@ public class UnwrappingRepositoryInvokerFactoryUnitTests {
|
||||
verify(lookup, times(1)).lookupEntity(eq(1L));
|
||||
}
|
||||
|
||||
private void assertFindOneValueForSource(Object source, Matcher<Object> value) {
|
||||
|
||||
when(invoker.invokeFindOne(1L)).thenReturn(source);
|
||||
assertThat(factory.getInvokerFor(Object.class).invokeFindOne(1L), value);
|
||||
}
|
||||
|
||||
private void assertQueryValueForSource(Object source, Matcher<Object> value) {
|
||||
|
||||
when(invoker.invokeQueryMethod(method, new LinkedMultiValueMap<String, Object>(), null, null)).thenReturn(source);
|
||||
assertThat(factory.getInvokerFor(Object.class).invokeQueryMethod(method, new LinkedMultiValueMap<String, Object>(),
|
||||
null, null), value);
|
||||
private static Consumer<AbstractOptionalAssert<?, Object>> $(Consumer<AbstractOptionalAssert<?, Object>> consumer) {
|
||||
return consumer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.rest.core.util;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class FunctionTests {
|
||||
|
||||
@Test
|
||||
public void foo() {
|
||||
|
||||
Foo foo = new Foo();
|
||||
|
||||
foo.apply(new Function<String, Integer>() {
|
||||
|
||||
@Override
|
||||
public Integer apply(String input) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static class Foo {
|
||||
|
||||
public Integer apply(Function<String, Integer> function) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
18
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/util/MethodsUnitTests.java
Normal file → Executable file
18
spring-data-rest-core/src/test/java/org/springframework/data/rest/core/util/MethodsUnitTests.java
Normal file → Executable file
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.rest.core.util;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
@@ -25,7 +24,6 @@ import java.util.Set;
|
||||
import org.junit.Test;
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.ReflectionUtils.MethodCallback;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link Methods}.
|
||||
@@ -41,18 +39,12 @@ public class MethodsUnitTests {
|
||||
factory.setTarget(new Sample());
|
||||
factory.setProxyTargetClass(true);
|
||||
|
||||
final Set<Method> methods = new HashSet<Method>();
|
||||
Set<Method> methods = new HashSet<Method>();
|
||||
|
||||
ReflectionUtils.doWithMethods(factory.getProxy().getClass(), new MethodCallback() {
|
||||
ReflectionUtils.doWithMethods(factory.getProxy().getClass(), method -> methods.add(method), Methods.USER_METHODS);
|
||||
|
||||
@Override
|
||||
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
|
||||
methods.add(method);
|
||||
}
|
||||
}, Methods.USER_METHODS);
|
||||
|
||||
assertThat(methods, hasSize(1));
|
||||
assertThat(methods, contains(Sample.class.getMethod("method")));
|
||||
assertThat(methods).hasSize(1);
|
||||
assertThat(methods).contains(Sample.class.getMethod("method"));
|
||||
}
|
||||
|
||||
static class Sample {
|
||||
|
||||
Reference in New Issue
Block a user