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);
}
}
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);
}
}
Aggregations