/*******************************************************************************
 * Copyright 2015, Medidata Solutions, Inc., All Rights Reserved. The program
 * and the accompanying materials are made under the terms of MIT license.
 * Author: Nan Li, nli@mdsol.com
 ******************************************************************************/
package com.mdsol.skyfire;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.uml2.uml.FinalState;
import org.eclipse.uml2.uml.Pseudostate;
import org.eclipse.uml2.uml.Region;
import org.eclipse.uml2.uml.State;
import org.eclipse.uml2.uml.StateMachine;
import org.eclipse.uml2.uml.Vertex;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * A JUnit test case for class {@link StateMachineAccessor}
 *
 * @author Nan Li
 * @version 1.0 Nov 28, 2012
 *
 */
public class StateMachineAccessorIT {

    private final String vendingMachineXmlPath = System.getProperty("user.dir")
            + "/src/test/resources/testData/VendingMachine/model/VendingMachineFSM.uml";

    /**
     * @throws java.lang.Exception
     */
    @Before
    public void setUp() throws Exception {
    }

    /**
     * @throws java.lang.Exception
     */
    @After
    public void tearDown() throws Exception {
    }

    @Test
    public void testGetStateMachines() throws IOException {
        EObject object = ModelAccessor.getModelObject(vendingMachineXmlPath);
        List<StateMachine> statemachines = ModelAccessor.getStateMachines(object);
        assertEquals(1, statemachines.size());
    }

    @Test
    public void testGetRegions() throws IOException {
        EObject object = ModelAccessor.getModelObject(vendingMachineXmlPath);
        List<StateMachine> statemachines = ModelAccessor.getStateMachines(object);
        List<Region> regions = StateMachineAccessor.getRegions(statemachines.get(0));
        assertEquals(1, regions.size());
    }

    @Test
    public void testGetInitialStates() throws IOException {
        EObject object = ModelAccessor.getModelObject(vendingMachineXmlPath);
        List<StateMachine> statemachines = ModelAccessor.getStateMachines(object);
        List<Region> regions = StateMachineAccessor.getRegions(statemachines.get(0));
        List<Pseudostate> initialStates = StateMachineAccessor.getInitialStates(regions.get(0));
        assertEquals(1, initialStates.size());
    }

    @Test
    public void testGetFinalStates() throws IOException {
        EObject object = ModelAccessor.getModelObject(vendingMachineXmlPath);
        List<StateMachine> statemachines = ModelAccessor.getStateMachines(object);
        List<Region> regions = StateMachineAccessor.getRegions(statemachines.get(0));
        List<FinalState> finalStates = StateMachineAccessor.getFinalStates(regions.get(0));
        assertEquals(1, finalStates.size());
    }

    @Test
    public void testGetStates() throws IOException {
        EObject object = ModelAccessor.getModelObject(vendingMachineXmlPath);
        List<StateMachine> statemachines = ModelAccessor.getStateMachines(object);
        List<Region> regions = StateMachineAccessor.getRegions(statemachines.get(0));
        List<State> states = StateMachineAccessor.getStates(regions.get(0));
        assertEquals(9, states.size());
    }

    @Test
    public void testCreateStateMappings() throws IOException {
        EObject object = StateMachineAccessor.getModelObject(vendingMachineXmlPath);
        List<StateMachine> statemachines = StateMachineAccessor.getStateMachines(object);
        List<Region> regions = StateMachineAccessor.getRegions(statemachines.get(0));
        StateMachineAccessor stateMachine = new StateMachineAccessor(regions.get(0));
        HashMap<Vertex, String> stateMappings = stateMachine.getStateMappings();
        HashMap<String, Vertex> reversedStateMappings = stateMachine.getReversedStateMappings();
        assertNotNull(stateMappings);
        assertEquals(11, stateMappings.size());
        assertEquals(11, reversedStateMappings.size());
        // System.out.println(reversedStateMappings);
        assertNotNull(stateMachine.getInitialStates());
        assertNotNull(stateMachine.getFinalStates());
        assertNotNull(stateMachine.getEdges());
        System.out.println(stateMachine.getEdges());
    }
}

@@ -539,16 +539,100 @@
 .List;%0A%0A
+import org.apache.logging.log4j.LogManager;%0Aimport org.apache.logging.log4j.Logger;%0A
 import o
@@ -661,16 +661,16 @@
 Object;%0A
-
 import o
@@ -895,57 +895,8 @@
 ex;%0A
-import org.junit.After;%0Aimport org.junit.Before;%0A
 impo
@@ -1248,235 +1248,90 @@
 l%22;%0A
-%0A
     
-/**%0A     * @throws java.lang.Exception%0A     */%0A    @Before%0A    public void setUp() throws Exception %7B%0A    %7D%0A%0A    /**%0A     * @throws java.lang.Exception%0A     */%0A    @After%0A    public void tearDown() throws Exception %7B%0A    %7D
+private static Logger logger = LogManager.getLogger(%22StateMachineAccessorIT%22);
 %0A%0A  
@@ -3923,32 +3923,33 @@
 tateMappings();%0A
+%0A
         assertNo
@@ -4078,62 +4078,8 @@
 ));%0A
-        // System.out.println(reversedStateMappings);%0A
     
@@ -4244,26 +4244,19 @@
     
-System.out.println
+logger.info
 (sta

Fix critical issues reported by SonarQube in StateMachineAccessorIT