Junit class
@BeforeEach
void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
context.load().json("/pdf.json", "/content/dam");
context.currentResource("/content/dam");
AssetManager assetManager =context.resourceResolver().adaptTo(AssetManager.class);
Asset asset=context.resourceResolver().adaptTo(Asset.class);
//when(assetManager.getAsset("/content/dam/aemgeeks/file-sample_150kB.pdf")).thenReturn(assetManager.getAsset("/content/dam/aemgeeks/file-sample_150kB.pdf"));
request = new MockSlingHttpServletRequest(context.resourceResolver());
}
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @prakashvb ,
Try below bold libes of code-
@BeforeEach
void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
context.load().json("/pdf.json", "/content/dam");
context.currentResource("/content/dam");
AssetManager assetManager =context.resourceResolver().adaptTo(AssetManager.class);
//Asset asset=context.resourceResolver().adaptTo(Asset.class);
Asset asset = context.create().asset("/content/dam/aemgeeks/file-sample_150kB.pdf", 1, 1, "application/pdf");
when(assetManager.getAsset("/content/dam/aemgeeks/file-sample_150kB.pdf")).thenReturn(asset);
request = new MockSlingHttpServletRequest(context.resourceResolver());
}
Hi @prakashvb ,
Try below bold libes of code-
@BeforeEach
void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
context.load().json("/pdf.json", "/content/dam");
context.currentResource("/content/dam");
AssetManager assetManager =context.resourceResolver().adaptTo(AssetManager.class);
//Asset asset=context.resourceResolver().adaptTo(Asset.class);
Asset asset = context.create().asset("/content/dam/aemgeeks/file-sample_150kB.pdf", 1, 1, "application/pdf");
when(assetManager.getAsset("/content/dam/aemgeeks/file-sample_150kB.pdf")).thenReturn(asset);
request = new MockSlingHttpServletRequest(context.resourceResolver());
}
Views
Like
Replies
Views
Likes
Replies