Search in sources :

Example 21 with IResource

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

the class ServerAdapterPropertyTester method isServerAdapterAllowed.

private boolean isServerAdapterAllowed(Object receiver, Object[] args, Object expectedValue) {
    if (!(receiver instanceof IResource) || !(expectedValue instanceof Boolean)) {
        return false;
    }
    IResource resource = (IResource) receiver;
    Boolean allowed = OpenShiftServerUtils.isAllowedForServerAdapter(resource);
    return ((Boolean) expectedValue).equals(allowed);
}
Also used : IResource(com.openshift.restclient.model.IResource)

Example 22 with IResource

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

the class DockerImageLabelsTest method setup.

@Before
public void setup() throws IOException {
    this.connection = createConnection("https://localhost:8181", "aUser");
    this.labelsThatFailsToLoad = spy(new TestableDockerImageLabels(null, connection));
    this.dc = ResourceMocks.createDeploymentConfig("aDeploymentConfig", ResourceMocks.createProject("aProject"), null, null);
    IDeploymentImageChangeTrigger trigger = ResourceMocks.createDeploymentImageChangeTrigger(DeploymentTriggerType.IMAGE_CHANGE, "nodejs:latest");
    ResourceMocks.mockGetTriggers(Collections.singletonList(trigger), dc);
    IResource imageStreamTag = mockImageStreamTag(NODEJS_IMAGESTREAM_TAG_URL);
    doReturn(imageStreamTag).when(connection).getResource(eq(ResourceKind.IMAGE_STREAM_TAG), anyString(), anyString());
    this.labels = spy(new TestableDockerImageLabels(dc, connection));
}
Also used : IDeploymentImageChangeTrigger(com.openshift.restclient.model.deploy.IDeploymentImageChangeTrigger) IResource(com.openshift.restclient.model.IResource) Before(org.junit.Before)

Example 23 with IResource

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

the class DockerImageLabelsTest method mockImageStreamTag.

private IResource mockImageStreamTag(String url) throws IOException {
    IResource imageStreamTag = mock(IResource.class);
    doReturn(IOUtils.toString(DockerImageLabelsTest.class.getResourceAsStream(url))).when(imageStreamTag).toJson();
    return imageStreamTag;
}
Also used : IResource(com.openshift.restclient.model.IResource)

Example 24 with IResource

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

the class ConnectionsRegistryUtilTest method testConnectionNotFound.

@Test
public void testConnectionNotFound() {
    String kind = "foo";
    String name = "bar";
    try {
        IResource resource = mock(IResource.class);
        when(resource.getKind()).thenReturn(kind);
        when(resource.getName()).thenReturn(name);
        ConnectionsRegistryUtil.getConnectionFor(resource);
        fail();
    } catch (ConnectionNotFoundException e) {
        assertEquals("Unable to find the connection for a " + kind + " named " + name, e.getMessage());
    }
}
Also used : ConnectionNotFoundException(org.jboss.tools.openshift.core.connection.ConnectionNotFoundException) IResource(com.openshift.restclient.model.IResource) Test(org.junit.Test)

Example 25 with IResource

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

the class CreateResourceJobTest method shouldNotifyAndReturnWarningStatusWhenResourcesAlreadyExist.

/*
	 * Display failed resources and end wizard
	 */
@Test
public void shouldNotifyAndReturnWarningStatusWhenResourcesAlreadyExist() {
    IResource resource = mock(IResource.class);
    when(resource.getKind()).thenReturn(ResourceKind.IMAGE_STREAM);
    IResource status = mock(com.openshift.restclient.model.IStatus.class);
    when(status.getKind()).thenReturn(ResourceKind.STATUS);
    resources.add(status);
    when(resourceFactory.create(input)).thenReturn(resource);
    when(client.create(resource, project.getNamespaceName())).thenReturn(status);
    IStatus result = job.runMe();
    assertEquals(IStatus.OK, result.getSeverity());
    assertEquals(resources, job.getResource());
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IResource(com.openshift.restclient.model.IResource) Test(org.junit.Test)

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