Search in sources :

Example 1 with CFTarget

use of org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget in project sts4 by spring-projects.

the class CFClientTest method testServicesFromTarget.

@Test
public void testServicesFromTarget() throws Exception {
    ClientRequests client = cloudfoundry.client;
    CFServiceInstance service = Mockito.mock(CFServiceInstance.class);
    when(service.getName()).thenReturn("appdb");
    when(service.getPlan()).thenReturn("spark");
    when(service.getService()).thenReturn("cleardb");
    when(client.getServices()).thenReturn(ImmutableList.of(service));
    CFTarget target = targetCache.getOrCreate().get(0);
    assertEquals("appdb", target.getServices().get(0).getName());
    assertEquals("spark", target.getServices().get(0).getPlan());
    assertEquals("cleardb", target.getServices().get(0).getService());
}
Also used : CFTarget(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget) Test(org.junit.Test)

Example 2 with CFTarget

use of org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget in project sts4 by spring-projects.

the class CFClientTest method testNoServicesFromTarget.

@Test
public void testNoServicesFromTarget() throws Exception {
    ClientRequests client = cloudfoundry.client;
    when(client.getServices()).thenReturn(ImmutableList.of());
    CFTarget target = targetCache.getOrCreate().get(0);
    assertTrue(target.getServices().isEmpty());
}
Also used : CFTarget(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget) Test(org.junit.Test)

Example 3 with CFTarget

use of org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget in project sts4 by spring-projects.

the class CFClientTest method testDomainsFromTarget.

@Test
public void testDomainsFromTarget() throws Exception {
    ClientRequests client = cloudfoundry.client;
    CFDomain domain = Mockito.mock(CFDomain.class);
    when(domain.getName()).thenReturn("cfapps.io");
    when(client.getDomains()).thenReturn(ImmutableList.of(domain));
    CFTarget target = targetCache.getOrCreate().get(0);
    assertEquals("cfapps.io", target.getDomains().get(0).getName());
}
Also used : CFTarget(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget) Test(org.junit.Test)

Example 4 with CFTarget

use of org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget in project sts4 by spring-projects.

the class CFClientTest method testUnknownHostDomains.

@Test
public void testUnknownHostDomains() throws Exception {
    ClientRequests client = cloudfoundry.client;
    when(client.getDomains()).thenThrow(new UnknownHostException("api.run.pivotal.io"));
    CFTarget target = targetCache.getOrCreate().get(0);
    assertError(() -> target.getDomains(), ConnectionException.class, expectedMessages.noNetworkConnection());
}
Also used : CFTarget(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget) UnknownHostException(java.net.UnknownHostException) Test(org.junit.Test)

Example 5 with CFTarget

use of org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget in project sts4 by spring-projects.

the class CFClientTest method testBuildpacksFromTarget.

@Test
public void testBuildpacksFromTarget() throws Exception {
    ClientRequests client = cloudfoundry.client;
    CFBuildpack buildpack = Mockito.mock(CFBuildpack.class);
    when(buildpack.getName()).thenReturn("java_buildpack");
    when(client.getBuildpacks()).thenReturn(ImmutableList.of(buildpack));
    CFTarget target = targetCache.getOrCreate().get(0);
    assertEquals("java_buildpack", target.getBuildpacks().get(0).getName());
}
Also used : CFTarget(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget) Test(org.junit.Test)

Aggregations

CFTarget (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget)10 Test (org.junit.Test)9 UnknownHostException (java.net.UnknownHostException)3 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Callable (java.util.concurrent.Callable)1 Ignore (org.junit.Ignore)1 CFBuildpack (org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack)1 CFTargetCache (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTargetCache)1 ConnectionException (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ConnectionException)1 NoTargetsException (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException)1 Assert (org.springframework.ide.vscode.commons.util.Assert)1 ExceptionUtil (org.springframework.ide.vscode.commons.util.ExceptionUtil)1 ValueParseException (org.springframework.ide.vscode.commons.util.ValueParseException)1 YValueHint (org.springframework.ide.vscode.commons.yaml.schema.YValueHint)1