활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.
활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.
Hi everyone, I was trying to create a Junit test for my ImagePlus component, an image to which I added a getName. I initialized the test in setUp like so:
@ExtendWith({AemContextExtension.class, MockitoExtension.class})
class ImagePlusTest {
private final AemContext ctx = new AemContext();
private ImagePlus image;
@Mock
private ModelFactory modelFactory;
@BeforeEach
void setup() {
ctx.addModelsForClasses(ImagePlus.class);
ctx.load().json("mypath/ImagePlusTest.json", "/content");
ctx.registerService(ModelFactory.class, modelFactory, Constants.SERVICE_RANKING, Integer.MAX_VALUE);
ctx.currentResource("/content/image");
image = ctx.request().adaptTo(ImagePlus.class);
}
I don't understand why the image is set to null in the adapter. I've read that it might be that the implementation doesn't support the target type, but what can I do in this case? How do I see which types are supported or not?
해결되었습니다! 솔루션으로 이동.
조회 수
답글
좋아요 수
I solved it by myself, the problem was in how to initialize a resource via the referenced Json file. All the fields that the image needs to be inserted into the environment must be entered
Hi Santosh, it has this
(adaptables = SlingHttpServletRequest.class
@Model(adaptables = {SlingHttpServletRequest.class, Resource.class})
Should work, try this and let us know.
조회 수
답글
좋아요 수
Sorry, Nothing change.
조회 수
답글
좋아요 수
I solved it by myself, the problem was in how to initialize a resource via the referenced Json file. All the fields that the image needs to be inserted into the environment must be entered