Search in sources :

Example 1 with TAzureStorageDeleteProperties

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();
}
Also used : RuntimeContainerMock(org.talend.components.azurestorage.RuntimeContainerMock) TAzureStorageConnectionProperties(org.talend.components.azurestorage.tazurestorageconnection.TAzureStorageConnectionProperties) TAzureStorageDeleteProperties(org.talend.components.azurestorage.blob.tazurestoragedelete.TAzureStorageDeleteProperties) Before(org.junit.Before)

Example 2 with TAzureStorageDeleteProperties

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();
}
Also used : ValidationResult(org.talend.daikon.properties.ValidationResult) TAzureStorageDeleteProperties(org.talend.components.azurestorage.blob.tazurestoragedelete.TAzureStorageDeleteProperties) AzureStorageBlobService(org.talend.components.azurestorage.blob.AzureStorageBlobService)

Example 3 with TAzureStorageDeleteProperties

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);
}
Also used : RemoteBlobsTable(org.talend.components.azurestorage.blob.helpers.RemoteBlobsTable) ArrayList(java.util.ArrayList) TAzureStorageDeleteProperties(org.talend.components.azurestorage.blob.tazurestoragedelete.TAzureStorageDeleteProperties) BoundedReader(org.talend.components.api.component.runtime.BoundedReader) Test(org.junit.Test)

Aggregations

TAzureStorageDeleteProperties (org.talend.components.azurestorage.blob.tazurestoragedelete.TAzureStorageDeleteProperties)3 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 Test (org.junit.Test)1 BoundedReader (org.talend.components.api.component.runtime.BoundedReader)1 RuntimeContainerMock (org.talend.components.azurestorage.RuntimeContainerMock)1 AzureStorageBlobService (org.talend.components.azurestorage.blob.AzureStorageBlobService)1 RemoteBlobsTable (org.talend.components.azurestorage.blob.helpers.RemoteBlobsTable)1 TAzureStorageConnectionProperties (org.talend.components.azurestorage.tazurestorageconnection.TAzureStorageConnectionProperties)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1