Search in sources :

Example 1 with ConnectionWrapper

use of org.jboss.tools.openshift.internal.ui.models.ConnectionWrapper in project jbosstools-openshift by jbosstools.

the class ConnectionWrapperTest method prepareData.

@Before
public void prepareData() throws Exception {
    this.project = mock(IProject.class);
    when(project.getName()).thenReturn(NAMESPACE);
    when(project.getNamespaceName()).thenReturn(NAMESPACE);
    IOpenShiftConnection connection = mock(IOpenShiftConnection.class);
    when(connection.isDefaultHost()).thenReturn(true);
    when(connection.getUsername()).thenReturn("bdshadow");
    when(connection.getResources(eq(ResourceKind.PROJECT))).thenReturn(Arrays.asList(new IResource[] { project }));
    // by doing this we call a protected OpenshiftUIModel constructor, which adds listener to the
    OpenshiftUIModel.getInstance();
    // ConnectionsRegistrySingleton
    ConnectionsRegistrySingleton.getInstance().add(connection);
    ConnectionWrapper connectionWrapper = OpenshiftUIModel.getInstance().getConnectionWrapperForConnection(connection);
    connectionWrapper.refresh();
    this.projectWrapper = (ProjectWrapper) connectionWrapper.getResources().iterator().next();
    this.resource = mock(IBuildConfig.class);
    when(this.resource.getKind()).thenReturn(ResourceKind.BUILD_CONFIG);
    when(this.resource.getNamespaceName()).thenReturn(NAMESPACE);
    when(this.resource.getProject()).thenReturn(project);
    this.watchListener = new WatchListenerTestable(WatchManager.getInstance(), project, connection, ResourceKind.BUILD_CONFIG, 0, 0);
    watchListener.setState("CONNECTED");
}
Also used : IOpenShiftConnection(org.jboss.tools.openshift.core.connection.IOpenShiftConnection) IBuildConfig(com.openshift.restclient.model.IBuildConfig) ConnectionWrapper(org.jboss.tools.openshift.internal.ui.models.ConnectionWrapper) IProject(com.openshift.restclient.model.IProject) IResource(com.openshift.restclient.model.IResource) Before(org.junit.Before)

Example 2 with ConnectionWrapper

use of org.jboss.tools.openshift.internal.ui.models.ConnectionWrapper in project jbosstools-openshift by jbosstools.

the class ProjectWrapperTest method initilize.

@Before
public void initilize() {
    this.connection = mock(IOpenShiftConnection.class);
    this.connectionWrapper = new ConnectionWrapper(mock(OpenshiftUIModel.class), connection);
    this.project = mock(IProject.class);
    when(project.getNamespaceName()).thenReturn("namespace");
    this.projectWrapper = new ProjectWrapper(connectionWrapper, project);
    WatchManager.getInstance()._getWatches().clear();
}
Also used : ProjectWrapper(org.jboss.tools.openshift.internal.ui.models.ProjectWrapper) IOpenShiftConnection(org.jboss.tools.openshift.core.connection.IOpenShiftConnection) ConnectionWrapper(org.jboss.tools.openshift.internal.ui.models.ConnectionWrapper) IProject(com.openshift.restclient.model.IProject) Before(org.junit.Before)

Aggregations

IProject (com.openshift.restclient.model.IProject)2 IOpenShiftConnection (org.jboss.tools.openshift.core.connection.IOpenShiftConnection)2 ConnectionWrapper (org.jboss.tools.openshift.internal.ui.models.ConnectionWrapper)2 Before (org.junit.Before)2 IBuildConfig (com.openshift.restclient.model.IBuildConfig)1 IResource (com.openshift.restclient.model.IResource)1 ProjectWrapper (org.jboss.tools.openshift.internal.ui.models.ProjectWrapper)1