Skip to content

Commit

Permalink
add tests for adaptTo methods
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Aug 20, 2024
1 parent 7e76056 commit 6e166f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
Expand Down Expand Up @@ -225,4 +226,10 @@ public void testGraniteAdaptation() {
assertEquals(graniteAsset.adaptTo(Resource.class), asset.adaptTo(Resource.class));
}

@Test
public void testAdaptTo() {
assertSame(asset, asset.adaptTo(Asset.class));
assertSame(asset, asset.adaptTo(com.adobe.granite.asset.api.Asset.class).adaptTo(Asset.class));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;

import org.apache.sling.api.resource.Resource;
import org.junit.Before;
Expand Down Expand Up @@ -76,7 +77,7 @@ public void testSize() {
}

@Test
public void testEquals() throws Exception {
public void testEquals() {
Rendition rendition1 = this.context.resourceResolver()
.getResource("/content/dam/sample/portraits/scott_reynolds.jpg/jcr:content/renditions/original").adaptTo(Rendition.class);
Rendition rendition2 = this.context.resourceResolver()
Expand All @@ -88,4 +89,10 @@ public void testEquals() throws Exception {
assertNotEquals(rendition1, rendition3);
}

@Test
public void testAdaptTo() {
assertSame(rendition, rendition.adaptTo(Rendition.class));
assertSame(rendition, rendition.adaptTo(com.adobe.granite.asset.api.Rendition.class));
}

}

0 comments on commit 6e166f2

Please sign in to comment.