use of org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer in project jbosstools-openshift by jbosstools.
the class CDK3LaunchController method initialize.
@Override
public void initialize(ILaunchConfigurationWorkingCopy wc) throws CoreException {
final IServer s = getServerFromLaunch(wc);
final CDKServer cdkServer = (CDKServer) s.loadAdapter(CDKServer.class, new NullProgressMonitor());
// for testing purposes.
// we can't mock final methods like getServer(), so we need to be creative
initialize(wc, cdkServer.getUsername(), cdkServer.getServer());
}
use of org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer in project jbosstools-openshift by jbosstools.
the class CDK32LaunchControllerTest method testSetupWithMinishiftHome.
@Test
public void testSetupWithMinishiftHome() throws Exception {
ILaunchConfigurationWorkingCopy wc = mock(ILaunchConfigurationWorkingCopy.class);
when(wc.getAttribute(any(String.class), any(String.class))).thenAnswer(AdditionalAnswers.returnsSecondArg());
when(wc.getName()).thenReturn(NAME);
String userName = "Drumpf";
IPath msHome = CDKTestActivator.getDefault().getStateLocation().append("test927");
msHome.toFile().mkdirs();
IServer server = mockServerWithMSHome(msHome);
ArgumentCaptor<String> keyCaptor = ArgumentCaptor.forClass(String.class);
Class<Map<String, String>> mapClass = (Class<Map<String, String>>) (Class) Map.class;
ArgumentCaptor<Map<String, String>> valCaptor = ArgumentCaptor.forClass(mapClass);
CDKServer cdkServer = (CDKServer) server.loadAdapter(CDKServer.class, new NullProgressMonitor());
CDK3TestLaunchController controller = new CDK3TestLaunchController(server, cdkServer);
controller.setupLaunchConfiguration(wc, new NullProgressMonitor());
verify(wc, Mockito.times(2)).setAttribute(keyCaptor.capture(), valCaptor.capture());
List<String> allKeys = keyCaptor.getAllValues();
List<Map<String, String>> allVals = valCaptor.getAllValues();
Map<String, String> latest = allVals.get(allVals.size() - 1);
String val1 = latest.get("MINISHIFT_HOME");
assertEquals(msHome.toOSString(), val1);
}
use of org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer in project jbosstools-openshift by jbosstools.
the class CDKCredentialSection method createSection.
@Override
public void createSection(Composite parent) {
super.createSection(parent);
CDKServer cdkServer = (CDKServer) server.getOriginal().loadAdapter(CDKServer.class, new NullProgressMonitor());
FormToolkit toolkit = new FormToolkit(parent.getDisplay());
Composite composite = createWidgets(parent, cdkServer, toolkit);
toolkit.paintBordersFor(composite);
section.setClient(composite);
}
use of org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer in project jbosstools-openshift by jbosstools.
the class CDKLaunchControllerTest method mockServer.
private IServer mockServer() {
IServer server = mock(IServer.class);
when(server.getAttribute(CDKServer.PROP_PASS_CREDENTIALS, false)).thenReturn(Boolean.TRUE);
when(server.getAttribute(CDKServer.PROP_USER_ENV_VAR, CDKConstants.CDK_ENV_SUB_USERNAME)).thenReturn(CDKConstants.CDK_ENV_SUB_USERNAME);
CDKServer cdk = mock(CDKServer.class);
when(cdk.passCredentials()).thenReturn(Boolean.TRUE);
when(cdk.getUserEnvironmentKey()).thenReturn(CDKConstants.CDK_ENV_SUB_USERNAME);
when(server.loadAdapter(eq(CDKServer.class), any(IProgressMonitor.class))).thenReturn(cdk);
return server;
}
Aggregations