use of org.jboss.tools.openshift.io.core.model.IAccount in project jbosstools-openshift by jbosstools.
the class MainPreferencePage method updateLabel.
void updateLabel() {
String msg;
if (removed || osioCluster.getAccounts().isEmpty()) {
msg = "No configured accounts";
} else {
IAccount account = osioCluster.getAccounts().get(0);
msg = account.getId() + " account configured valid until " + Date.from(Instant.ofEpochMilli(account.getAccessTokenExpiryTime()));
}
label.setText(msg);
}
use of org.jboss.tools.openshift.io.core.model.IAccount 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.IAccount in project jbosstools-openshift by jbosstools.
the class AccountServiceTest method checkRefreshIsRequiredIfAccessTokenExpired.
@Test
public void checkRefreshIsRequiredIfAccessTokenExpired() {
IAccount account = cluster.createAccount("myid");
account.setAccessToken("at");
account.setRefreshToken("rt");
account.setAccessTokenExpiryTime(System.currentTimeMillis() - 1000);
AccountStatus status = service.getStatus(account);
assertEquals(AccountStatus.NEEDS_REFRESH, status);
}
use of org.jboss.tools.openshift.io.core.model.IAccount in project jbosstools-openshift by jbosstools.
the class AccountServiceTest method checkValidIfAccessedRecentry.
@Test
public void checkValidIfAccessedRecentry() {
IAccount account = cluster.createAccount("myid");
account.setAccessToken("at");
account.setRefreshToken("rt");
account.setLastRefreshedTime(System.currentTimeMillis());
AccountStatus status = service.getStatus(account);
assertEquals(AccountStatus.VALID, status);
}
Aggregations