Search in sources :

Example 1 with IAccountModel

use of org.jboss.tools.openshift.io.core.model.IAccountModel in project jbosstools-openshift by jbosstools.

the class AccountModelTest method testAddRemoveAccount.

@Test
public void testAddRemoveAccount() {
    IAccountModel m = AccountService.getDefault().getModel();
    assertNotNull(m);
    final Boolean[] checkAdded = new Boolean[] { false };
    final Boolean[] checkRemoved = new Boolean[] { false };
    IAccountModelListener listener = new AccountModelAdapter() {

        @Override
        public void accountAdded(IAccountModel source, IAccount account) {
            checkAdded[0] = true;
        }

        @Override
        public void accountRemoved(IAccountModel source, IAccount account) {
            checkRemoved[0] = true;
        }
    };
    m.addListener(listener);
    try {
        ICluster cluster = m.createCluster("id1");
        m.addCluster(cluster);
        List<ICluster> clusters = m.getClusters();
        assertEquals(2, clusters.size());
        assertEquals(0, cluster.getAccounts().size());
        IAccount account = cluster.createAccount("id2");
        cluster.addAccount(account);
        assertEquals(1, cluster.getAccounts().size());
        cluster.removeAccount(account);
        assertEquals(0, cluster.getAccounts().size());
        m.removeCluster(cluster);
        clusters = m.getClusters();
        assertEquals(1, clusters.size());
        assertTrue(checkAdded[0]);
        assertTrue(checkRemoved[0]);
    } finally {
        m.removeListener(listener);
    }
}
Also used : IAccountModel(org.jboss.tools.openshift.io.core.model.IAccountModel) IAccount(org.jboss.tools.openshift.io.core.model.IAccount) IAccountModelListener(org.jboss.tools.openshift.io.core.model.IAccountModelListener) ICluster(org.jboss.tools.openshift.io.core.model.ICluster) AccountModelAdapter(org.jboss.tools.openshift.io.core.model.AccountModelAdapter) Test(org.junit.Test)

Example 2 with IAccountModel

use of org.jboss.tools.openshift.io.core.model.IAccountModel in project jbosstools-openshift by jbosstools.

the class AccountModelTest method testAddRemoveCluster.

@Test
public void testAddRemoveCluster() {
    IAccountModel m = AccountService.getDefault().getModel();
    assertNotNull(m);
    final Boolean[] checkAdded = new Boolean[] { false };
    final Boolean[] checkRemoved = new Boolean[] { false };
    IAccountModelListener listener = new AccountModelAdapter() {

        @Override
        public void clusterAdded(IAccountModel source, ICluster cluster) {
            checkAdded[0] = true;
        }

        @Override
        public void clusterRemoved(IAccountModel source, ICluster cluster) {
            checkRemoved[0] = true;
        }
    };
    m.addListener(listener);
    try {
        ICluster cluster = m.createCluster("id1");
        m.addCluster(cluster);
        List<ICluster> clusters = m.getClusters();
        assertEquals(2, clusters.size());
        m.removeCluster(cluster);
        clusters = m.getClusters();
        assertEquals(1, clusters.size());
        assertTrue(checkAdded[0]);
        assertTrue(checkRemoved[0]);
    } finally {
        m.removeListener(listener);
    }
}
Also used : IAccountModel(org.jboss.tools.openshift.io.core.model.IAccountModel) IAccountModelListener(org.jboss.tools.openshift.io.core.model.IAccountModelListener) ICluster(org.jboss.tools.openshift.io.core.model.ICluster) AccountModelAdapter(org.jboss.tools.openshift.io.core.model.AccountModelAdapter) Test(org.junit.Test)

Aggregations

AccountModelAdapter (org.jboss.tools.openshift.io.core.model.AccountModelAdapter)2 IAccountModel (org.jboss.tools.openshift.io.core.model.IAccountModel)2 IAccountModelListener (org.jboss.tools.openshift.io.core.model.IAccountModelListener)2 ICluster (org.jboss.tools.openshift.io.core.model.ICluster)2 Test (org.junit.Test)2 IAccount (org.jboss.tools.openshift.io.core.model.IAccount)1