use of com.openshift.restclient.model.IImageStream in project jbosstools-openshift by jbosstools.
the class OpenShiftExplorerLabelProviderTest method getStyledTextForAnImageRepository.
@Test
public void getStyledTextForAnImageRepository() {
IImageStream repo = givenAResource(IImageStream.class, ResourceKind.IMAGE_STREAM);
when(repo.getDockerImageRepository()).thenReturn(new DockerImageURI("127.0.0.1", "foo", "bar"));
assertEquals(repo.getName() + " " + repo.getDockerImageRepository(), provider.getStyledText(repo).getString());
}
use of com.openshift.restclient.model.IImageStream in project jbosstools-openshift by jbosstools.
the class DeployImageJobTest method testStubImageStreamWhereOneDoesNotExistAndImageIsPublic.
@Test
public void testStubImageStreamWhereOneDoesNotExistAndImageIsPublic() {
givenAnImageStreamTo("foo", null);
givenTheImageIsVisible(true);
IImageStream is = whenStubbingTheImageStream();
assertNotNull("Exp. an IS to be returned", is);
assertEquals(RESOURCE_NAME, is.getName());
assertEquals(project.getName(), is.getNamespaceName());
assertEquals(1, is.getTags().size());
assertEquals(DOCKER_TAG.toString(), is.getTags().iterator().next().getFrom().getName());
}
use of com.openshift.restclient.model.IImageStream in project jbosstools-openshift by jbosstools.
the class NewApplicationWizardModelTest method setDefaultAppLabelForImageBasedApplications.
@Test
public void setDefaultAppLabelForImageBasedApplications() {
// pre-conditions
IApplicationSource source = mock(IApplicationSource.class);
when(source.getKind()).thenReturn(ResourceKind.IMAGE_STREAM);
IImageStream imageStream = mock(IImageStream.class);
when(source.getSource()).thenReturn(imageStream);
when(imageStream.getName()).thenReturn("my-image-stream");
// operations
model.setServerAppSource(source);
// verification
verify(model, Mockito.times(1)).setLabels(Arrays.asList(new Label("app", "my-image-stream")));
}
use of com.openshift.restclient.model.IImageStream in project jbosstools-openshift by jbosstools.
the class ApplicationSourceTreeItems method loadImageStreams.
private Collection<IApplicationSource> loadImageStreams(IProject project, Connection conn) {
final Collection<IImageStream> streams = conn.getResources(ResourceKind.IMAGE_STREAM, project.getNamespaceName());
try {
if (StringUtils.isNotBlank(conn.getClusterNamespace())) {
Collection<IImageStream> commonStreams = conn.getResources(ResourceKind.IMAGE_STREAM, (String) conn.getClusterNamespace());
commonStreams.stream().filter(s -> !streams.contains(s)).forEach(s -> streams.add(s));
}
} catch (OpenShiftException e) {
OpenShiftUIActivator.log(IStatus.ERROR, e.getLocalizedMessage(), e);
}
Collection<IApplicationSource> sources = new ArrayList<>();
for (IImageStream is : streams) {
List<ITagReference> tags = is.getTags().stream().filter(t -> t.isAnnotatedWith(OpenShiftAPIAnnotations.TAGS) && ArrayUtils.contains(t.getAnnotation(OpenShiftAPIAnnotations.TAGS).split(","), BUILDER_TAG)).collect(Collectors.toList());
if (!tags.isEmpty()) {
tags.forEach(t -> sources.add(new ImageStreamApplicationSource(is, t)));
}
}
return sources;
}
use of com.openshift.restclient.model.IImageStream in project jbosstools-openshift by jbosstools.
the class DeployImageJobTest method givenAnImageStreamTo.
private IImageStream givenAnImageStreamTo(String namespace, DockerImageURI uri) {
IImageStream is = mock(IImageStream.class);
when(is.getNamespaceName()).thenReturn(namespace);
when(is.getName()).thenReturn(IMAGE_STREAM_NAME);
when(is.getDockerImageRepository()).thenReturn(uri);
List<IResource> streams = Arrays.asList(is);
Connection conn = mock(Connection.class);
when(conn.getResources(anyString(), eq(namespace))).thenReturn(streams);
when(conn.getClusterNamespace()).thenReturn(ICommonAttributes.COMMON_NAMESPACE);
when(parameters.getConnection()).thenReturn(conn);
return is;
}
Aggregations