Skip to content

Commit c26b181

Browse files
committed
#363 Updated IncludesTest
1 parent 6e41ff0 commit c26b181

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

activejdbc/src/main/java/org/javalite/activejdbc/LazyList.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ public <E extends Model> LazyList<E> orderBy(String orderBy){
161161
* relationship.
162162
* @return instance of this <code>LazyList</code>
163163
*/
164-
public <E extends Model> LazyList<E> include(Class<? extends Model> ... classes){
165-
if(includes.size() != 0) throw new IllegalArgumentException("Can't call include() more than once!");
164+
public <E extends Model> LazyList<E> include(Class<? extends Model>... classes) {
165+
if (!includes.isEmpty()) { throw new IllegalArgumentException("Can't call include() more than once!"); }
166166

167167
for (Class<? extends Model> clazz : classes) {
168168
if(!metaModel.isAssociatedTo(clazz)) throw new IllegalArgumentException("Model: " + clazz.getName() + " is not associated with: " + metaModel.getModelClass().getName());

activejdbc/src/test/java/org/javalite/activejdbc/IncludesTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
/*
2-
Copyright 2009-2014 Igor Polevoy
2+
Copyright 2009-2015 Igor Polevoy
33
4-
Licensed under the Apache License, Version 2.0 (the "License");
5-
you may not use this file except in compliance with the License.
6-
You may obtain a copy of the License at
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
77
8-
http://www.apache.org/licenses/LICENSE-2.0
8+
http://www.apache.org/licenses/LICENSE-2.0
99
10-
Unless required by applicable law or agreed to in writing, software
11-
distributed under the License is distributed on an "AS IS" BASIS,
12-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
See the License for the specific language governing permissions and
14-
limitations under the License.
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
1515
*/
1616

1717
package org.javalite.activejdbc;
1818

19-
import org.javalite.activejdbc.LazyList;
2019
import org.javalite.activejdbc.test.ActiveJDBCTest;
2120
import org.javalite.activejdbc.test_models.*;
2221
import org.junit.Test;
@@ -40,7 +39,6 @@ public void shouldBeAbleToIncludeParentOne2Many() {
4039
user = (Map)addresses.get(6).toMap().get("user");
4140
a(user.get("first_name")).shouldBeEqual("John");
4241
}
43-
4442

4543
@Test
4644
public void shouldBeAbleToIncludeChildrenOne2Many() {
@@ -163,6 +161,8 @@ public void shouldFixDefect163NeedsToIncludeChildrenAndParentsInTreeStructure(){
163161

164162
//should return cached parent in both cases
165163
a(parent1).shouldBeTheSameAs(parent2);
164+
165+
the(parent1.get("name")).shouldBeEqual("Car");
166166
}
167167

168168
@Test(expected = IllegalArgumentException.class)

0 commit comments

Comments
 (0)