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