use of com.openshift.restclient.capability.resources.IClientCapability in project jbosstools-openshift by jbosstools.
the class CreateResourceJobTest method setUp.
@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
job = spy(new CreateResourceJobRunner(project, input));
when(client.get(anyString(), anyString(), anyString())).thenThrow(OpenShiftException.class);
when(client.getResourceFactory()).thenReturn(resourceFactory);
when(clientCapability.getClient()).thenReturn(client);
when(project.accept(isA(CapabilityVisitor.class), any())).thenAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock args) throws Throwable {
if (args.getArguments()[1] instanceof IStatus) {
CapabilityVisitor<IClientCapability, IStatus> visitor = (CapabilityVisitor<IClientCapability, IStatus>) args.getArguments()[0];
return visitor.visit(clientCapability);
}
return null;
}
});
}
use of com.openshift.restclient.capability.resources.IClientCapability 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.capability.resources.IClientCapability in project jbosstools-openshift by jbosstools.
the class CreateApplicationFromTemplateJobTest method setUp.
@SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
labels.add(new Label("foo", "bar"));
job = spy(new CreateApplicationFromTemplateJobRunner(project, template, parameters, labels));
when(client.get(anyString(), anyString(), anyString())).thenThrow(OpenShiftException.class);
when(clientCapability.getClient()).thenReturn(client);
when(project.accept(isA(CapabilityVisitor.class), any())).thenAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock args) throws Throwable {
if (args.getArguments()[1] instanceof IStatus) {
CapabilityVisitor<IProjectTemplateProcessing, IStatus> visitor = (CapabilityVisitor<IProjectTemplateProcessing, IStatus>) args.getArguments()[0];
return visitor.visit(capability);
} else if (args.getArguments()[1] instanceof Collection) {
CapabilityVisitor<IClientCapability, Collection> visitor = (CapabilityVisitor<IClientCapability, Collection>) args.getArguments()[0];
return visitor.visit(clientCapability);
}
return null;
}
});
}
Aggregations