use of com.adobe.acs.commons.functions.CheckedConsumer in project acs-aem-commons by Adobe-Consulting-Services.
the class AssetFolderCreatorTest method setUp.
@Before
public void setUp() throws Exception {
context.create().resource("/content/dam", JcrConstants.JCR_PRIMARYTYPE, "sling:Folder");
context.resourceResolver().commit();
final Map<String, ResourceDefinitionBuilder> resourceDefinitionBuilders = new HashMap<>();
resourceDefinitionBuilders.put(AssetFolderCreator.AssetFolderBuilder.LOWERCASE_WITH_DASHES.name(), new LowercaseWithDashesDefinitionBuilderImpl());
resourceDefinitionBuilders.put(AssetFolderCreator.AssetFolderBuilder.TITLE_AND_NODE_NAME.name(), new TitleAndNodeNameDefinitionBuilderImpl());
resourceDefinitionBuilders.put(AssetFolderCreator.AssetFolderBuilder.TITLE_TO_NODE_NAME.name(), new JcrValidNameDefinitionBuilderImpl());
assetFolderCreator = new AssetFolderCreator(resourceDefinitionBuilders);
assetFolderCreator.excelFile = getClass().getResourceAsStream("/com/adobe/acs/commons/mcp/impl/processes/asset-folder-creator.xlsx");
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
CheckedConsumer<ResourceResolver> method = (CheckedConsumer<ResourceResolver>) invocation.getArguments()[0];
method.accept(context.resourceResolver());
return null;
}
}).when(actionManager).withResolver(any(CheckedConsumer.class));
}
use of com.adobe.acs.commons.functions.CheckedConsumer in project acs-aem-commons by Adobe-Consulting-Services.
the class S3AssetIngestorTest method setup.
@Before
public void setup() throws PersistenceException {
context.registerAdapter(ResourceResolver.class, AssetManager.class, new Function<ResourceResolver, AssetManager>() {
@Nullable
@Override
public AssetManager apply(@Nullable ResourceResolver input) {
return assetManager;
}
});
context.create().resource("/content/dam", JcrConstants.JCR_PRIMARYTYPE, "sling:Folder");
context.resourceResolver().commit();
ingestor = new S3AssetIngestor(context.getService(MimeTypeService.class));
ingestor.jcrBasePath = "/content/dam";
ingestor.ignoreFileList = Collections.emptyList();
ingestor.ignoreExtensionList = Collections.emptyList();
ingestor.ignoreFolderList = Arrays.asList(".ds_store");
ingestor.existingAssetAction = AssetIngestor.AssetAction.skip;
int port = FreePortFinder.findFreeLocalPort();
s3Mock = new S3Mock.Builder().withPort(port).withInMemoryBackend().build();
s3Mock.start();
S3ClientOptions options = S3ClientOptions.builder().setPathStyleAccess(true).build();
s3Client = new AmazonS3Client(new AnonymousAWSCredentials());
s3Client.setS3ClientOptions(options);
s3Client.setEndpoint("http://localhost:" + port);
ingestor.s3Client = s3Client;
ingestor.bucket = TEST_BUCKET;
s3Client.createBucket(TEST_BUCKET);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
CheckedConsumer<ResourceResolver> method = (CheckedConsumer<ResourceResolver>) invocation.getArguments()[0];
method.accept(context.resourceResolver());
return null;
}
}).when(actionManager).deferredWithResolver(any(CheckedConsumer.class));
}
use of com.adobe.acs.commons.functions.CheckedConsumer in project acs-aem-commons by Adobe-Consulting-Services.
the class FileAssetIngestorTest method setup.
@Before
public void setup() throws PersistenceException {
context.registerAdapter(ResourceResolver.class, AssetManager.class, new Function<ResourceResolver, AssetManager>() {
@Nullable
@Override
public AssetManager apply(@Nullable ResourceResolver input) {
return assetManager;
}
});
context.create().resource("/content/dam", JcrConstants.JCR_PRIMARYTYPE, "sling:Folder");
context.resourceResolver().commit();
ingestor = new FileAssetIngestor(context.getService(MimeTypeService.class));
ingestor.jcrBasePath = "/content/dam";
ingestor.ignoreFileList = Collections.emptyList();
ingestor.ignoreExtensionList = Collections.emptyList();
ingestor.ignoreFolderList = Arrays.asList(".ds_store");
ingestor.existingAssetAction = AssetIngestor.AssetAction.skip;
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
CheckedConsumer<ResourceResolver> method = (CheckedConsumer<ResourceResolver>) invocation.getArguments()[0];
method.accept(context.resourceResolver());
return null;
}
}).when(actionManager).deferredWithResolver(any(CheckedConsumer.class));
tempDirectory = Files.createTempDir();
ingestor.fileBasePath = tempDirectory.getAbsolutePath();
}
Aggregations