use of org.talend.components.azurestorage.blob.tazurestoragedelete.TAzureStorageDeleteProperties in project components by Talend.
the class AzureStorageDeleteRuntimeTest method setup.
@Before
public void setup() {
properties = new TAzureStorageDeleteProperties(PROP_ + "DeleteBlock");
properties.setupProperties();
// valid connection
properties.connection = new TAzureStorageConnectionProperties(PROP_ + "Connection");
properties.connection.protocol.setValue(Protocol.HTTP);
properties.connection.accountName.setValue("fakeAccountName");
properties.connection.accountKey.setValue("fakeAccountKey=ANBHFYRJJFHRIKKJFU");
properties.container.setValue("valide-container-name-1");
runtimeContainer = new RuntimeContainerMock();
this.deleteBlock = new AzureStorageDeleteRuntime();
}
use of org.talend.components.azurestorage.blob.tazurestoragedelete.TAzureStorageDeleteProperties in project components by Talend.
the class AzureStorageDeleteRuntime method initialize.
@Override
public ValidationResult initialize(RuntimeContainer runtimeContainer, ComponentProperties properties) {
ValidationResult validationResult = super.initialize(runtimeContainer, properties);
if (validationResult.getStatus() == ValidationResult.Result.ERROR) {
return validationResult;
}
TAzureStorageDeleteProperties componentProperties = (TAzureStorageDeleteProperties) properties;
remoteBlobsTable = componentProperties.remoteBlobs;
this.dieOnError = componentProperties.dieOnError.getValue();
this.azureStorageBlobService = new AzureStorageBlobService(getAzureConnection(runtimeContainer));
return componentProperties.remoteBlobs.getValidationResult();
}
use of org.talend.components.azurestorage.blob.tazurestoragedelete.TAzureStorageDeleteProperties in project components by Talend.
the class AzureStorageDeleteReaderTestIT method testBlobDelete.
@SuppressWarnings("rawtypes")
@Test
public void testBlobDelete() throws Exception {
TAzureStorageDeleteProperties props = new TAzureStorageDeleteProperties("tests");
props.container.setValue(CONTAINER);
setupConnectionProperties(props);
RemoteBlobsTable rmt = new RemoteBlobsTable("tests");
List<String> pfx = new ArrayList<>();
List<Boolean> inc = new ArrayList<>();
pfx.add("");
inc.add(false);
rmt.prefix.setValue(pfx);
rmt.include.setValue(inc);
props.remoteBlobs = rmt;
BoundedReader reader = createBoundedReader(props);
assertTrue(reader.start());
List<String> blobs = listAllBlobs(CONTAINER);
// blob1.txt, blob2.txt & blob3.txt should be deleted
for (String b : TEST_ROOT_BLOBS) assertFalse(isInBlobList(b, blobs));
// the others should exist
for (String b : TEST_SUB_BLOBS) assertTrue(isInBlobList(b, blobs));
//
// delete sub1 and sub3
//
pfx.clear();
pfx.add("sub1/");
pfx.add("sub3/");
inc.clear();
inc.add(true);
inc.add(true);
rmt.prefix.setValue(pfx);
rmt.include.setValue(inc);
props.remoteBlobs = rmt;
reader = createBoundedReader(props);
assertTrue(reader.start());
blobs = listAllBlobs(CONTAINER);
for (String b : TEST_ROOT_BLOBS) assertFalse(isInBlobList(b, blobs));
for (String b : TEST_SUB1_BLOBS) assertFalse(isInBlobList(b, blobs));
for (String b : TEST_SUB3_BLOBS) assertFalse(isInBlobList(b, blobs));
// the others should exist
for (String b : TEST_SUB2_BLOBS) assertTrue(isInBlobList(b, blobs));
//
// finally delete everything
//
pfx.clear();
pfx.add("");
inc.clear();
inc.add(true);
rmt.prefix.setValue(pfx);
rmt.include.setValue(inc);
props.remoteBlobs = rmt;
reader = createBoundedReader(props);
assertTrue(reader.start());
blobs = listAllBlobs(CONTAINER);
assertTrue(blobs.size() == 0);
}
Aggregations