diff --git a/agrest-cayenne/src/test/java/io/agrest/cayenne/path/EntityPathCacheTest.java b/agrest-cayenne/src/test/java/io/agrest/cayenne/path/EntityPathCacheTest.java index ed1be84b4..b537da9ac 100644 --- a/agrest-cayenne/src/test/java/io/agrest/cayenne/path/EntityPathCacheTest.java +++ b/agrest-cayenne/src/test/java/io/agrest/cayenne/path/EntityPathCacheTest.java @@ -60,6 +60,28 @@ public void getOrCreate_Attribute() { assertSame(pd, cache.getOrCreate("name")); } + @Test + public void getOrCreate_Id() { + EntityPathCache cache = new EntityPathCache(x); + PathDescriptor pd = cache.getOrCreate("id"); + assertNotNull(pd); + assertTrue(pd.isAttributeOrId()); + assertEquals("java.lang.String", pd.getType()); + assertEquals("pkx1", pd.getPathExp().getPath()); + assertSame(pd, cache.getOrCreate("id")); + } + + @Test + public void getOrCreate_RelatedId() { + EntityPathCache cache = new EntityPathCache(x); + PathDescriptor pd = cache.getOrCreate("y.db:pk1"); + assertNotNull(pd); + assertTrue(pd.isAttributeOrId()); + assertEquals("java.lang.Integer", pd.getType()); + assertEquals("pk1", pd.getPathExp().getPath()); + assertSame(pd, cache.getOrCreate("y.db:pk1")); + } + @Test public void getOrCreate_Relationship() { EntityPathCache cache = new EntityPathCache(x); @@ -83,7 +105,7 @@ public void getOrCreate_RelatedAttribute() { } @Test - public void tesGetOrCreate_BadPath() { + public void getOrCreate_BadPath() { EntityPathCache cache = new EntityPathCache(x); assertThrows(AgException.class, () -> cache.getOrCreate("y.xyz")); }