|
|
@ -6,7 +6,7 @@ import org.testng.annotations.Test;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.LifecycleManagementException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.exception.LifecycleManagementException;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.config.Configuration;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.config.Configuration;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManger;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.lifecycle.LifecycleStateManager;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.lifecycle.config.LifecycleState;
|
|
|
|
import org.wso2.carbon.device.application.mgt.core.lifecycle.config.LifecycleState;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
@ -15,72 +15,70 @@ import java.util.Set;
|
|
|
|
public class LifecycleManagementTest {
|
|
|
|
public class LifecycleManagementTest {
|
|
|
|
|
|
|
|
|
|
|
|
private List<LifecycleState> lifecycleStates;
|
|
|
|
private List<LifecycleState> lifecycleStates;
|
|
|
|
private LifecycleStateManger lifecycleStateManger;
|
|
|
|
private LifecycleStateManager lifecycleStateManager;
|
|
|
|
|
|
|
|
|
|
|
|
private final String CURRENT_STATE = "Approved";
|
|
|
|
private final String CURRENT_STATE = "Approved";
|
|
|
|
private final String NEXT_STATE = "Published";
|
|
|
|
private final String NEXT_STATE = "Published";
|
|
|
|
private final String BOGUS_STATE = "Removed";
|
|
|
|
private final String BOGUS_STATE = "Removed";
|
|
|
|
private final String UPDATABLE_STATE = "Created";
|
|
|
|
private final String UPDATABLE_STATE = "Created";
|
|
|
|
private final String NON_UPDATABLE_STATE= "Removed";
|
|
|
|
private final String NON_UPDATABLE_STATE = "Removed";
|
|
|
|
private final String INSTALLABLE_STATE = "Published";
|
|
|
|
private final String INSTALLABLE_STATE = "Published";
|
|
|
|
private final String UNINSTALlABLE_STATE = "Removed";
|
|
|
|
private final String UNINSTALlABLE_STATE = "Removed";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
@BeforeClass
|
|
|
|
public void init() throws LifecycleManagementException {
|
|
|
|
public void init() throws LifecycleManagementException {
|
|
|
|
ConfigurationManager configurationManager = ConfigurationManager.getInstance();
|
|
|
|
ConfigurationManager configurationManager = ConfigurationManager.getInstance();
|
|
|
|
Configuration configuration = configurationManager.getConfiguration();
|
|
|
|
Configuration configuration = configurationManager.getConfiguration();
|
|
|
|
lifecycleStates = configuration.getLifecycleStates();
|
|
|
|
lifecycleStates = configuration.getLifecycleStates();
|
|
|
|
lifecycleStateManger = new LifecycleStateManger();
|
|
|
|
lifecycleStateManager = new LifeCycleStateManagerTest();
|
|
|
|
lifecycleStateManger.initializeLifeCycleDetails(lifecycleStates);
|
|
|
|
((LifeCycleStateManagerTest) lifecycleStateManager).initializeLifeCycleDetails(lifecycleStates);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void checkValidNextLifecycleState() {
|
|
|
|
public void checkValidNextLifecycleState() {
|
|
|
|
Set<String> proceedingStates = lifecycleStateManger.getNextLifecycleStates(CURRENT_STATE);
|
|
|
|
Set<String> proceedingStates = lifecycleStateManager.getNextLifecycleStates(CURRENT_STATE);
|
|
|
|
Assert.assertTrue("Invalid proceeding state of: " + CURRENT_STATE,
|
|
|
|
Assert.assertTrue("Invalid proceeding state of: " + CURRENT_STATE,
|
|
|
|
proceedingStates.contains(NEXT_STATE.toUpperCase()));
|
|
|
|
proceedingStates.contains(NEXT_STATE.toUpperCase()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void checkInvalidNextLifecycleState() {
|
|
|
|
public void checkInvalidNextLifecycleState() {
|
|
|
|
Set<String> proceedingStates = lifecycleStateManger.getNextLifecycleStates(CURRENT_STATE);
|
|
|
|
Set<String> proceedingStates = lifecycleStateManager.getNextLifecycleStates(CURRENT_STATE);
|
|
|
|
Assert.assertFalse("Invalid proceeding state of: " + CURRENT_STATE,
|
|
|
|
Assert.assertFalse("Invalid proceeding state of: " + CURRENT_STATE,
|
|
|
|
proceedingStates.contains(BOGUS_STATE.toUpperCase()));
|
|
|
|
proceedingStates.contains(BOGUS_STATE.toUpperCase()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void CheckUpdatableState() {
|
|
|
|
public void CheckUpdatableState() {
|
|
|
|
Boolean isUpdatable = lifecycleStateManger.isUpdatable(UPDATABLE_STATE);
|
|
|
|
Boolean isUpdatable = lifecycleStateManager.isUpdatable(UPDATABLE_STATE);
|
|
|
|
System.out.println(isUpdatable);
|
|
|
|
System.out.println(isUpdatable);
|
|
|
|
Assert.assertTrue("Updatable state: " + UPDATABLE_STATE, isUpdatable);
|
|
|
|
Assert.assertTrue("Updatable state: " + UPDATABLE_STATE, isUpdatable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void CheckNonUpdatableState() {
|
|
|
|
public void CheckNonUpdatableState() {
|
|
|
|
Boolean isUpdatable = lifecycleStateManger.isUpdatable(NON_UPDATABLE_STATE);
|
|
|
|
Boolean isUpdatable = lifecycleStateManager.isUpdatable(NON_UPDATABLE_STATE);
|
|
|
|
Assert.assertFalse("Non Updatable state: " + CURRENT_STATE, isUpdatable);
|
|
|
|
Assert.assertFalse("Non Updatable state: " + NON_UPDATABLE_STATE, isUpdatable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void CheckInstallableState() {
|
|
|
|
public void CheckInstallableState() {
|
|
|
|
Boolean isInstallable = lifecycleStateManger.isInstallable(INSTALLABLE_STATE);
|
|
|
|
Boolean isInstallable = lifecycleStateManager.isInstallable(INSTALLABLE_STATE);
|
|
|
|
Assert.assertTrue("Installable state: " + INSTALLABLE_STATE,isInstallable);
|
|
|
|
Assert.assertTrue("Installable state: " + INSTALLABLE_STATE, isInstallable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void CheckUnInstallableState() {
|
|
|
|
public void CheckUnInstallableState() {
|
|
|
|
Boolean isInstallable = lifecycleStateManger.isInstallable(UNINSTALlABLE_STATE);
|
|
|
|
Boolean isInstallable = lifecycleStateManager.isInstallable(UNINSTALlABLE_STATE);
|
|
|
|
Assert.assertFalse("UnInstallable state: " + UNINSTALlABLE_STATE,isInstallable);
|
|
|
|
Assert.assertFalse("UnInstallable state: " + UNINSTALlABLE_STATE, isInstallable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void check() {
|
|
|
|
public void check() {
|
|
|
|
Set<String> proceedingStates = lifecycleStateManger.getNextLifecycleStates(CURRENT_STATE);
|
|
|
|
Set<String> proceedingStates = lifecycleStateManager.getNextLifecycleStates(CURRENT_STATE);
|
|
|
|
Assert.assertFalse("Invalid proceeding state of: " + CURRENT_STATE,
|
|
|
|
Assert.assertFalse("Invalid proceeding state of: " + CURRENT_STATE,
|
|
|
|
proceedingStates.contains(BOGUS_STATE.toUpperCase()));
|
|
|
|
proceedingStates.contains(BOGUS_STATE.toUpperCase()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|