Search in sources :

Example 6 with CFTarget

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

the class CFClientTest method testOneTarget.

@Test
public void testOneTarget() throws Exception {
    CFTarget target = targetCache.getOrCreate().get(0);
    assertNotNull(target);
    assertEquals(MockCfCli.DEFAULT_PARAMS, target.getParams());
}
Also used : CFTarget(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget) Test(org.junit.Test)

Example 7 with CFTarget

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

the class CFClientTest method testUnknownHostServices.

@Test
public void testUnknownHostServices() throws Exception {
    ClientRequests client = cloudfoundry.client;
    when(client.getServices()).thenThrow(new UnknownHostException("api.run.pivotal.io"));
    CFTarget target = targetCache.getOrCreate().get(0);
    assertError(() -> target.getServices(), 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 8 with CFTarget

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

the class CFClientTest method testUnknownHostBuildpacks.

@Test
public void testUnknownHostBuildpacks() throws Exception {
    ClientRequests client = cloudfoundry.client;
    when(client.getBuildpacks()).thenThrow(new UnknownHostException("api.run.pivotal.io"));
    CFTarget target = targetCache.getOrCreate().get(0);
    assertError(() -> target.getBuildpacks(), 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 9 with CFTarget

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

the class ManifestYamlActualCfClientTest method testGetBuildpacks.

@Ignore
@Test
public void testGetBuildpacks() throws Exception {
    List<CFTarget> targets = cfTargetCache.getOrCreate();
    assertTrue(targets.size() == 1);
    CFTarget target = targets.get(0);
    List<CFBuildpack> buildpacks = target.getBuildpacks();
    assertTrue(!buildpacks.isEmpty());
}
Also used : CFTarget(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget) CFBuildpack(org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 10 with CFTarget

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

the class AbstractCFHintsProvider method getHints.

/**
 * @return non-null list of hints. Return empty if no hints available
 */
protected Collection<YValueHint> getHints(List<CFTarget> targets) throws Exception {
    if (targets == null || targets.isEmpty()) {
        // this "don't know" value will suppress bogus warnings in the reconciler.
        return null;
    }
    List<YValueHint> hints = new ArrayList<>();
    boolean validTargetsPresent = false;
    for (CFTarget cfTarget : targets) {
        try {
            // TODO: check if duplicate proposals can be the list of all hints. Duplicates don't seem to cause duplicate proposals. Verify this!
            getHints(cfTarget).stream().filter(hint -> !hints.contains(hint)).forEach(hint -> hints.add(hint));
            validTargetsPresent = true;
        } catch (Exception e) {
        // Drop individual target error
        }
    }
    if (validTargetsPresent) {
        return hints;
    } else {
        throw new ConnectionException(targetCache.getCfClientConfig().getClientParamsProvider().getMessages().noNetworkConnection());
    }
}
Also used : ExceptionUtil(org.springframework.ide.vscode.commons.util.ExceptionUtil) Collection(java.util.Collection) Callable(java.util.concurrent.Callable) CFTarget(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget) Assert(org.springframework.ide.vscode.commons.util.Assert) NoTargetsException(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ValueParseException(org.springframework.ide.vscode.commons.util.ValueParseException) ConnectionException(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ConnectionException) CFTargetCache(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTargetCache) YValueHint(org.springframework.ide.vscode.commons.yaml.schema.YValueHint) CFTarget(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget) ArrayList(java.util.ArrayList) YValueHint(org.springframework.ide.vscode.commons.yaml.schema.YValueHint) NoTargetsException(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException) ValueParseException(org.springframework.ide.vscode.commons.util.ValueParseException) ConnectionException(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ConnectionException) ConnectionException(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ConnectionException)

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