Github user milanchandna commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2158#discussion_r140503820
  
    --- Diff: 
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/test/java/org/apache/nifi/processors/adls/TestPutADLSFile.java
 ---
    @@ -0,0 +1,522 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.nifi.processors.adls;
    +
    +import com.microsoft.azure.datalake.store.ADLStoreClient;
    +import com.microsoft.azure.datalake.store.ADLStoreOptions;
    +import okhttp3.mockwebserver.MockResponse;
    +import okhttp3.mockwebserver.MockWebServer;
    +import okhttp3.mockwebserver.QueueDispatcher;
    +import okhttp3.mockwebserver.RecordedRequest;
    +import org.apache.nifi.processor.Processor;
    +import org.apache.nifi.reporting.InitializationException;
    +import org.apache.nifi.util.TestRunner;
    +import org.apache.nifi.util.TestRunners;
    +import org.hamcrest.CoreMatchers;
    +import org.junit.Assert;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +import java.io.ByteArrayInputStream;
    +import java.io.IOException;
    +import java.io.InputStream;
    +import java.nio.file.Paths;
    +import java.util.HashMap;
    +import java.util.Map;
    +import java.util.concurrent.TimeUnit;
    +
    +
    +public class TestPutADLSFile {
    +
    +    private MockWebServer server;
    +    private ADLStoreClient client;
    +    private Processor processor;
    +    private TestRunner runner;
    +    Map<String, String> fileAttributes;
    +
    +    @Before
    +    public void init() throws IOException, InitializationException {
    +        server = new MockWebServer();
    +        QueueDispatcher dispatcher = new QueueDispatcher();
    +        dispatcher.setFailFast(new MockResponse().setResponseCode(400));
    +        server.setDispatcher(dispatcher);
    +        server.start();
    +        String accountFQDN = server.getHostName() + ":" + server.getPort();
    +        String dummyToken = "testDummyAadToken";
    +
    +        client = ADLStoreClient.createClient(accountFQDN, dummyToken);
    +        client.setOptions(new ADLStoreOptions().setInsecureTransport());
    +
    +        processor = new PutADLSWithMockClient(client);
    +
    +        runner = TestRunners.newTestRunner(processor);
    +
    +        runner.setProperty(ADLSConstants.ACCOUNT_NAME, accountFQDN);
    +        runner.setProperty(ADLSConstants.CLIENT_ID, "foobar");
    +        runner.setProperty(ADLSConstants.CLIENT_SECRET, "foobar");
    +        runner.setProperty(ADLSConstants.AUTH_TOKEN_ENDPOINT, "foobar");
    +        runner.setProperty(PutADLSFile.DIRECTORY, "/sample/");
    +        runner.setProperty(PutADLSFile.CONFLICT_RESOLUTION, 
PutADLSFile.FAIL_RESOLUTION_AV);
    +        runner.removeProperty(PutADLSFile.UMASK);
    +        runner.removeProperty(PutADLSFile.ACL);
    +
    +        fileAttributes = new HashMap<>();
    +        fileAttributes.put("filename", "sample.txt");
    +        fileAttributes.put("path", "/root/");
    +    }
    +
    +    @Test
    +    public void testPutConflictFail() throws IOException, 
InterruptedException {
    +
    +        //for create call
    +        server.enqueue(new MockResponse().setResponseCode(200));
    +        //for append call(internal call while writing to stream)
    +        server.enqueue(new MockResponse().setResponseCode(200));
    +        //for rename call(since its fail conflict)
    +        server.enqueue(new 
MockResponse().setResponseCode(200).setBody("{\"boolean\":true}"));
    +        //for delete call(removing temp file)
    +        server.enqueue(new MockResponse().setResponseCode(200));
    +
    +//        String bodySimpleFileContent = new 
String(Files.readAllBytes(Paths.get(bodySimpleFileName)));
    --- End diff --
    
    yes, removed.


---

Reply via email to