Search in sources :

Example 1 with IWatcher

use of com.openshift.restclient.IWatcher in project jbosstools-openshift by jbosstools.

the class WatchManager method startWatch.

public void startWatch(final IProject project, final IOpenShiftConnection connection) {
    AtomicReference<IWatcher> watcherRef = new AtomicReference<>();
    for (String kind : KINDS) {
        if (watches.putIfAbsent(new WatchKey(connection, project, kind), watcherRef) == null) {
            WatchListener listener = new WatchListener(project, connection, kind, 0, 0);
            startWatch(project, 0, 0, listener);
        }
    }
}
Also used : IOpenShiftWatchListener(com.openshift.restclient.IOpenShiftWatchListener) IWatcher(com.openshift.restclient.IWatcher) AtomicReference(java.util.concurrent.atomic.AtomicReference)

Example 2 with IWatcher

use of com.openshift.restclient.IWatcher in project jbosstools-openshift by jbosstools.

the class WatchManagerTest method testStartStopWatch.

@Test
@SuppressWarnings("unchecked")
public void testStartStopWatch() {
    // given
    when(project.accept(any(CapabilityVisitor.class), isNull())).thenReturn(client);
    IWatcher watchClient = mock(IWatcher.class);
    when(client.watch(any(), any(), any())).thenReturn(watchClient);
    // when - then
    WatchManager.getInstance().startWatch(project, connection);
    verify(client, timeout(200).times(WatchManager.KINDS.length)).watch(any(), any(), any());
    WatchManager.getInstance().stopWatch(project, connection);
    verify(watchClient, timeout(200).times(WatchManager.KINDS.length)).stop();
}
Also used : IWatcher(com.openshift.restclient.IWatcher) CapabilityVisitor(com.openshift.restclient.capability.CapabilityVisitor) Test(org.junit.Test)

Aggregations

IWatcher (com.openshift.restclient.IWatcher)2 IOpenShiftWatchListener (com.openshift.restclient.IOpenShiftWatchListener)1 CapabilityVisitor (com.openshift.restclient.capability.CapabilityVisitor)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Test (org.junit.Test)1