DATACMNS-621 - Polishing.

Simplified implementation of Path conversion. Inlined helper domain types to not to pollute the packages with types that are only used within that very one test class.

Original pull request: #111.
This commit is contained in:
Oliver Gierke
2015-01-20 16:24:30 +01:00
parent 95bda862e7
commit b2251aa5b9
5 changed files with 42 additions and 105 deletions

View File

@@ -17,6 +17,9 @@ package org.springframework.data.querydsl;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.springframework.data.querydsl.QQSortUnitTests_WrapperToWrapWrapperForUserWrapper.*;
import static org.springframework.data.querydsl.QQSortUnitTests_WrapperToWrapWrapperForUserWrapper_WrapperForUserWrapper.*;
import static org.springframework.data.querydsl.QQSortUnitTests_WrapperToWrapWrapperForUserWrapper_WrapperForUserWrapper_UserWrapper.*;
import java.util.List;
@@ -26,6 +29,7 @@ import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
import com.mysema.query.annotations.QueryInit;
import com.mysema.query.types.OrderSpecifier;
/**
@@ -171,7 +175,7 @@ public class QSortUnitTests {
@Test
public void shouldCreateSortForNestedPathCorrectly() {
QSort sort = new QSort(QUserWrapper.userWrapper.user.firstname.asc());
QSort sort = new QSort(userWrapper.user.firstname.asc());
assertThat(sort, hasItems(new Order(Direction.ASC, "user.firstname")));
}
@@ -182,7 +186,7 @@ public class QSortUnitTests {
@Test
public void shouldCreateSortForDeepNestedPathCorrectly() {
QSort sort = new QSort(QWrapperForUserWrapper.wrapperForUserWrapper.wrapper.user.firstname.asc());
QSort sort = new QSort(wrapperForUserWrapper.wrapper.user.firstname.asc());
assertThat(sort, hasItems(new Order(Direction.ASC, "wrapper.user.firstname")));
}
@@ -193,10 +197,27 @@ public class QSortUnitTests {
@Test
public void shouldCreateSortForReallyDeepNestedPathCorrectly() {
QSort sort = new QSort(
QWrapperToWrapWrapperForUserWrapper.wrapperToWrapWrapperForUserWrapper.wrapperForUserWrapper.wrapper.user.firstname
.asc());
QSort sort = new QSort(wrapperToWrapWrapperForUserWrapper.wrapperForUserWrapper.wrapper.user.firstname.asc());
assertThat(sort, hasItems(new Order(Direction.ASC, "wrapperForUserWrapper.wrapper.user.firstname")));
}
@com.mysema.query.annotations.QueryEntity
static class WrapperToWrapWrapperForUserWrapper {
@QueryInit("wrapper.user")//
WrapperForUserWrapper wrapperForUserWrapper;
@com.mysema.query.annotations.QueryEntity
static class WrapperForUserWrapper {
UserWrapper wrapper;
@com.mysema.query.annotations.QueryEntity
static class UserWrapper {
User user;
}
}
}
}

View File

@@ -1,28 +0,0 @@
/*
* Copyright 2015 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.querydsl;
import com.mysema.query.annotations.QueryEntity;
/**
* @author Christoph Strobl
*/
@QueryEntity
public class UserWrapper {
User user;
}

View File

@@ -1,28 +0,0 @@
/*
* Copyright 2015 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.querydsl;
import com.mysema.query.annotations.QueryEntity;
/**
* @author Christoph Strobl
*/
@QueryEntity
public class WrapperForUserWrapper {
UserWrapper wrapper;
}

View File

@@ -1,29 +0,0 @@
/*
* Copyright 2015 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.querydsl;
import com.mysema.query.annotations.QueryEntity;
import com.mysema.query.annotations.QueryInit;
/**
* @author Christoph Strobl
*/
@QueryEntity
public class WrapperToWrapWrapperForUserWrapper {
@QueryInit("wrapper.user")//
WrapperForUserWrapper wrapperForUserWrapper;
}