DATAREST-910 - Polishing.

Minor code reorganizations. Eagerly create SortTranslator to avoid repeated instantiation.

Original pull request: #232.
This commit is contained in:
Oliver Gierke
2016-12-06 11:57:11 +01:00
parent 0dc97dcc56
commit a4f88fe1ac
7 changed files with 63 additions and 40 deletions

View File

@@ -42,10 +42,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
*/
public class SortTranslatorUnitTests {
private ObjectMapper objectMapper = new ObjectMapper();
private KeyValueMappingContext mappingContext;
private PersistentEntities persistentEntities;
private SortTranslator sortTranslator;
ObjectMapper objectMapper = new ObjectMapper();
KeyValueMappingContext mappingContext;
PersistentEntities persistentEntities;
SortTranslator sortTranslator;
@Before
public void setUp() {

View File

@@ -13,12 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.rest.webmvc.json;
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Collections;
import java.util.List;
@@ -34,10 +37,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Unit tests for {@link WrappedProperties}.
*
@@ -45,9 +44,10 @@ import lombok.NoArgsConstructor;
*/
public class WrappedPropertiesUnitTests {
private static final ObjectMapper MAPPER = new ObjectMapper();
private KeyValueMappingContext mappingContext;
private PersistentEntities persistentEntities;
static final ObjectMapper MAPPER = new ObjectMapper();
KeyValueMappingContext mappingContext;
PersistentEntities persistentEntities;
@Before
public void setUp() {
@@ -55,6 +55,7 @@ public class WrappedPropertiesUnitTests {
mappingContext = new KeyValueMappingContext();
mappingContext.getPersistentEntity(MultiLevelNesting.class);
mappingContext.getPersistentEntity(SyntheticProperties.class);
persistentEntities = new PersistentEntities(Collections.singleton(mappingContext));
}

View File

@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.rest.webmvc.util;
import static org.hamcrest.Matchers.*;