Search in sources :

Example 31 with IResource

use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.

the class ServerResourceViewModel method updateResource.

protected IResource updateResource(final IResource resource, final List<ObservableTreeItem> resourceItems) {
    if (!isLoaded) {
        return resource;
    }
    IResource newResource = getResourceOrDefault(resource, resourceItems);
    firePropertyChange(PROPERTY_RESOURCE, null, this.resource = newResource);
    return newResource;
}
Also used : IResource(com.openshift.restclient.model.IResource)

Example 32 with IResource

use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.

the class ConnectionTest method givenAResourceThatAcceptsAVisitorForIClientCapability.

@SuppressWarnings("unchecked")
private Map<String, Object> givenAResourceThatAcceptsAVisitorForIClientCapability(IClient client) {
    final IClientCapability capability = mock(IClientCapability.class);
    when(capability.getClient()).thenReturn(client);
    IResource resource = mock(IResource.class);
    when(resource.accept(any(CapabilityVisitor.class), any())).thenAnswer(new Answer<IClient>() {

        @Override
        public IClient answer(InvocationOnMock invocation) throws Throwable {
            CapabilityVisitor<IClientCapability, IClient> visitor = (CapabilityVisitor<IClientCapability, IClient>) invocation.getArguments()[0];
            return visitor.visit(capability);
        }
    });
    Map<String, Object> mocks = new HashMap<>();
    mocks.put("capability", capability);
    mocks.put("resource", resource);
    return mocks;
}
Also used : IClientCapability(com.openshift.restclient.capability.resources.IClientCapability) HashMap(java.util.HashMap) InvocationOnMock(org.mockito.invocation.InvocationOnMock) IClient(com.openshift.restclient.IClient) CapabilityVisitor(com.openshift.restclient.capability.CapabilityVisitor) Matchers.anyString(org.mockito.Matchers.anyString) IResource(com.openshift.restclient.model.IResource)

Example 33 with IResource

use of com.openshift.restclient.model.IResource 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 34 with IResource

use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.

the class ServerSettingsWizardPageModelTest method shouldReturnServiceMatchingGitRemoteOfProjectModelWasInitializedWith.

@Test
public void shouldReturnServiceMatchingGitRemoteOfProjectModelWasInitializedWith() {
    // given
    // model initialized with project
    ServerSettingsWizardPageModel model = createModel(null, null, project2, Arrays.asList(project1, project2, project3, project4), connection);
    // when
    IResource resource = model.getResource();
    IProject deployProject = model.getDeployProject();
    // then
    assertThat(resource).isEqualTo(ResourceMocks.PROJECT2_SERVICES[1]);
    assertThat(deployProject).isEqualTo(project2);
}
Also used : ServerSettingsWizardPageModel(org.jboss.tools.openshift.internal.ui.server.ServerSettingsWizardPageModel) IResource(com.openshift.restclient.model.IResource) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 35 with IResource

use of com.openshift.restclient.model.IResource in project jbosstools-openshift by jbosstools.

the class OpenShiftLaunchController method getDockerImageLabels.

private DockerImageLabels getDockerImageLabels(OpenShiftServerBehaviour beh, IProgressMonitor monitor) {
    IResource resource = OpenShiftServerUtils.getResource(beh.getServer(), monitor);
    DockerImageLabels metadata = DockerImageLabels.getInstance(resource, beh);
    waitForDockerImageLabelsReady(metadata, monitor);
    return metadata;
}
Also used : DockerImageLabels(org.jboss.tools.openshift.core.server.DockerImageLabels) IResource(com.openshift.restclient.model.IResource)

Aggregations

IResource (com.openshift.restclient.model.IResource)101 Test (org.junit.Test)32 Connection (org.jboss.tools.openshift.core.connection.Connection)27 IProject (com.openshift.restclient.model.IProject)14 IStatus (org.eclipse.core.runtime.IStatus)12 Collection (java.util.Collection)10 ServerResourceViewModel (org.jboss.tools.openshift.internal.ui.server.ServerResourceViewModel)9 IReplicationController (com.openshift.restclient.model.IReplicationController)8 IService (com.openshift.restclient.model.IService)8 ArrayList (java.util.ArrayList)8 CoreException (org.eclipse.core.runtime.CoreException)8 IDeploymentConfig (com.openshift.restclient.model.IDeploymentConfig)7 Status (org.eclipse.core.runtime.Status)7 ISelection (org.eclipse.jface.viewers.ISelection)7 OpenShiftException (com.openshift.restclient.OpenShiftException)6 ResourceKind (com.openshift.restclient.ResourceKind)6 IPod (com.openshift.restclient.model.IPod)6 List (java.util.List)6 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 IBuildConfig (com.openshift.restclient.model.IBuildConfig)5