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);
}
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));
}
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;
}
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());
}
}
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());
}
Aggregations