Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / infrastructure / sdnc / tasks / SDNCRequestTasksTest.java
index 043aad4..b5d34ea 100644 (file)
@@ -25,18 +25,14 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
-
 import java.io.IOException;
 import java.io.StringReader;
 import java.nio.file.Files;
 import java.nio.file.Paths;
-
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
-
 import org.camunda.bpm.engine.delegate.BpmnError;
 import org.camunda.bpm.engine.delegate.DelegateExecution;
-
 import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
 import org.junit.Before;
 import org.junit.Rule;
@@ -57,128 +53,133 @@ import org.onap.so.client.sdnc.beans.SDNCRequest;
 import org.onap.so.client.sdnc.endpoint.SDNCTopology;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
-
 import com.fasterxml.jackson.core.JsonParseException;
 import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 @RunWith(MockitoJUnitRunner.class)
-public class SDNCRequestTasksTest extends SDNCRequestTasks{
-       
-       @Rule
-       public ExpectedException expectedException = ExpectedException.none();
-       
-       @InjectMocks
-       SDNCRequestTasks sndcRequestTasks = new SDNCRequestTasks();
-       
-       @Mock
-       SDNCClient sdncClient;
-       
-       @Spy
-       private ExceptionBuilder exceptionBuilder;
-       
-       protected DelegateExecution delegateExecution;
-       
-       
-       @Before
-       public void setup(){            
-       delegateExecution = new DelegateExecutionFake();
-       delegateExecution.setVariable("SDNCRequest", createSDNCRequest());      
-       }
-       
-       @Test
-       public void createCorrelationVariables_Test(){                  
-               sndcRequestTasks.createCorrelationVariables(delegateExecution);
-               assertEquals("correlationValue",delegateExecution.getVariable("correlationName_CORRELATOR"));
-       }
-       
-       @Test
-       public void callSDNC_Final_Test() throws MapperException, BadResponseException, IOException{     
-               final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientPut200Response.json")));      
-               doReturn(sdncResponse).when(sdncClient).post(createSDNCRequest().getSDNCPayload(),SDNCTopology.CONFIGURATION);          
-               sndcRequestTasks.callSDNC(delegateExecution);
-               assertEquals(true,delegateExecution.getVariable("isSDNCCompleted"));
-       }
-       
-       @Test
-       public void callSDNC_Not_Final_Test() throws MapperException, BadResponseException, IOException{         
-               final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json")));      
-               doReturn(sdncResponse).when(sdncClient).post(createSDNCRequest().getSDNCPayload(),SDNCTopology.CONFIGURATION);          
-               sndcRequestTasks.callSDNC(delegateExecution);
-               assertEquals(false,delegateExecution.getVariable("isSDNCCompleted"));
-       }
-       
-       @Test
-       public void callSDNC_Error_Test() throws MapperException, BadResponseException{  
-               doThrow(MapperException.class).when(sdncClient).post(createSDNCRequest().getSDNCPayload(),SDNCTopology.CONFIGURATION);
-               doReturn("processKey").when(exceptionBuilder).getProcessKey(delegateExecution);
-               expectedException.expect(BpmnError.class);
-               sndcRequestTasks.callSDNC(delegateExecution);           
-       }
-       
-       @Test
-       public void convertIndicatorToBoolean_True_Test() throws MapperException, BadResponseException{                 
-               boolean testValue = sndcRequestTasks.convertIndicatorToBoolean("Y");            
-               assertEquals(true,testValue);
-       }
-       
-       @Test
-       public void convertIndicatorToBoolean_False_Test() throws MapperException, BadResponseException{                        
-               boolean testValue = sndcRequestTasks.convertIndicatorToBoolean("N");            
-               assertEquals(false,testValue);
-       }
-       
-       @Test
-       public void HandleTimeout_Test() throws MapperException, BadResponseException{                                  
-               doReturn("processKey").when(exceptionBuilder).getProcessKey(delegateExecution);
-               expectedException.expect(BpmnError.class);
-               sndcRequestTasks.handleTimeOutException(delegateExecution);             
-       }
-       
-       @Test
-       public void processCallBack_Final_Test() throws MapperException, BadResponseException, IOException{
-               final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));    
-               delegateExecution.setVariable("correlationName_MESSAGE", sdncResponse);                 
-               sndcRequestTasks.processCallback(delegateExecution);            
-               assertEquals(true,delegateExecution.getVariable(IS_CALLBACK_COMPLETED));
-       }
-       
-       @Test
-       public void getXmlElementTest() throws Exception {
-               final String sdncResponse = new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));    
-        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance ();
+public class SDNCRequestTasksTest extends SDNCRequestTasks {
+
+    @Rule
+    public ExpectedException expectedException = ExpectedException.none();
+
+    @InjectMocks
+    SDNCRequestTasks sndcRequestTasks = new SDNCRequestTasks();
+
+    @Mock
+    SDNCClient sdncClient;
+
+    @Spy
+    private ExceptionBuilder exceptionBuilder;
+
+    protected DelegateExecution delegateExecution;
+
+
+    @Before
+    public void setup() {
+        delegateExecution = new DelegateExecutionFake();
+        delegateExecution.setVariable("SDNCRequest", createSDNCRequest());
+    }
+
+    @Test
+    public void createCorrelationVariables_Test() {
+        sndcRequestTasks.createCorrelationVariables(delegateExecution);
+        assertEquals("correlationValue", delegateExecution.getVariable("correlationName_CORRELATOR"));
+    }
+
+    @Test
+    public void callSDNC_Final_Test() throws MapperException, BadResponseException, IOException {
+        final String sdncResponse =
+                new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientPut200Response.json")));
+        doReturn(sdncResponse).when(sdncClient).post(createSDNCRequest().getSDNCPayload(), SDNCTopology.CONFIGURATION);
+        sndcRequestTasks.callSDNC(delegateExecution);
+        assertEquals(true, delegateExecution.getVariable("isSDNCCompleted"));
+    }
+
+    @Test
+    public void callSDNC_Not_Final_Test() throws MapperException, BadResponseException, IOException {
+        final String sdncResponse = new String(
+                Files.readAllBytes(Paths.get("src/test/resources/__files/SDNCClientPut200ResponseNotFinal.json")));
+        doReturn(sdncResponse).when(sdncClient).post(createSDNCRequest().getSDNCPayload(), SDNCTopology.CONFIGURATION);
+        sndcRequestTasks.callSDNC(delegateExecution);
+        assertEquals(false, delegateExecution.getVariable("isSDNCCompleted"));
+    }
+
+    @Test
+    public void callSDNC_Error_Test() throws MapperException, BadResponseException {
+        doThrow(MapperException.class).when(sdncClient).post(createSDNCRequest().getSDNCPayload(),
+                SDNCTopology.CONFIGURATION);
+        doReturn("processKey").when(exceptionBuilder).getProcessKey(delegateExecution);
+        expectedException.expect(BpmnError.class);
+        sndcRequestTasks.callSDNC(delegateExecution);
+    }
+
+    @Test
+    public void convertIndicatorToBoolean_True_Test() throws MapperException, BadResponseException {
+        boolean testValue = sndcRequestTasks.convertIndicatorToBoolean("Y");
+        assertEquals(true, testValue);
+    }
+
+    @Test
+    public void convertIndicatorToBoolean_False_Test() throws MapperException, BadResponseException {
+        boolean testValue = sndcRequestTasks.convertIndicatorToBoolean("N");
+        assertEquals(false, testValue);
+    }
+
+    @Test
+    public void HandleTimeout_Test() throws MapperException, BadResponseException {
+        doReturn("processKey").when(exceptionBuilder).getProcessKey(delegateExecution);
+        expectedException.expect(BpmnError.class);
+        sndcRequestTasks.handleTimeOutException(delegateExecution);
+    }
+
+    @Test
+    public void processCallBack_Final_Test() throws MapperException, BadResponseException, IOException {
+        final String sdncResponse =
+                new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
+        delegateExecution.setVariable("correlationName_MESSAGE", sdncResponse);
+        sndcRequestTasks.processCallback(delegateExecution);
+        assertEquals(true, delegateExecution.getVariable(IS_CALLBACK_COMPLETED));
+    }
+
+    @Test
+    public void getXmlElementTest() throws Exception {
+        final String sdncResponse =
+                new String(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Async_Request2.xml")));
+        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
         DocumentBuilder db;
-        db = dbf.newDocumentBuilder ();
-        Document doc = db.parse (new InputSource(new StringReader(sdncResponse)));
-        
+        db = dbf.newDocumentBuilder();
+        Document doc = db.parse(new InputSource(new StringReader(sdncResponse)));
+
         String finalMessageIndicator = getXmlElement(doc, "/input/ack-final-indicator");
         String responseCode = getXmlElement(doc, "/input/response-code");
-               String responseMessage = getXmlElement(doc, "/input/response-message"); 
-               
-               assertEquals("Y", finalMessageIndicator);
-               assertEquals("200", responseCode);
-               assertEquals("Success", responseMessage);
-       }
-       
-       public SDNCRequest createSDNCRequest(){
-               SDNCRequest request = new SDNCRequest();
-               request.setCorrelationName("correlationName");
-               request.setCorrelationValue("correlationValue");                
-               request.setTopology(SDNCTopology.CONFIGURATION);
-               ObjectMapper mapper = new ObjectMapper();
-               try {
-                       GenericResourceApiServiceOperationInformation sdncReq = 
-                                       mapper.readValue(Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Client_Request.json")), GenericResourceApiServiceOperationInformation.class);
-                       request.setSDNCPayload(sdncReq);
-               } catch (JsonParseException e) {                        
-                       
-               } catch (JsonMappingException e) {
-                       
-               } catch (IOException e) {
-                       
-               }
-               
-               return request;
-       }
-       
+        String responseMessage = getXmlElement(doc, "/input/response-message");
+
+        assertEquals("Y", finalMessageIndicator);
+        assertEquals("200", responseCode);
+        assertEquals("Success", responseMessage);
+    }
+
+    public SDNCRequest createSDNCRequest() {
+        SDNCRequest request = new SDNCRequest();
+        request.setCorrelationName("correlationName");
+        request.setCorrelationValue("correlationValue");
+        request.setTopology(SDNCTopology.CONFIGURATION);
+        ObjectMapper mapper = new ObjectMapper();
+        try {
+            GenericResourceApiServiceOperationInformation sdncReq = mapper.readValue(
+                    Files.readAllBytes(Paths.get("src/test/resources/__files/SDNC_Client_Request.json")),
+                    GenericResourceApiServiceOperationInformation.class);
+            request.setSDNCPayload(sdncReq);
+        } catch (JsonParseException e) {
+
+        } catch (JsonMappingException e) {
+
+        } catch (IOException e) {
+
+        }
+
+        return request;
+    }
+
 }