I have this method in a Directory model:
public List<Directory> subdirectories() {
return find("select d from Directory d where d.parent = ?", this.id).fetch()
}
And this test:
@Test
public void testSubdirectories() {
Directory d1 = Directory.find("byName", "d1").first();
Directory d2 = Directory.find("byName", "d2").first();
Directory d3 = Directory.find("byName", "d3").first();
Directory d4 = Directory.find("byName", "d4").first();
List<Directory> d1subs = d1.subdirectories();
List<Directory> d2subs = d2.subdirectories();
List<Directory> d3subs = d3.subdirectories();
List<Directory> d4subs = d4.subdirectories();
assertTrue(d1subs.contains(d2));
assertTrue(d1subs.contains(d3));
assertTrue(d2subs.isEmpty());
assertFalse(d1subs.contains(d4));
assertTrue(d3subs.contains(d4));
assertTrue(d4subs.isEmpty());
}
This typechecks, but when I run the tests, I get the following error:
A java.lang.IllegalArgumentException has been caught, Parameter value [5] was not matching type [models.Directory]
In /test/models/DirectoryTest.java, line 37 :
List<Directory> d1subs = d1.subdirectories();
Can anyone explain what the problem is, and how to fix it?
Shouldn’t this be
or a shortened version of the same should be