Example usage for org.springframework.ide.eclipse.boot.dash.model AbstractBootDashModel getRunTarget

List of usage examples for org.springframework.ide.eclipse.boot.dash.model AbstractBootDashModel getRunTarget

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.boot.dash.model AbstractBootDashModel getRunTarget.

Prototype

public RunTarget getRunTarget() 

Source Link

Usage

From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java

@Test
public void templateDrivenTargetNames() throws Exception {
    clientFactory.defSpace("my-org", "foo");
    clientFactory.defSpace("your-org", "bar");

    String apiUrl = "http://api.some-cloud.com";
    String username = "freddy";
    String password = "whocares";
    AbstractBootDashModel fooSpace = harness.createCfTarget(new CFClientParams(apiUrl, username,
            CFCredentials.fromPassword(password), false, "my-org", "foo", false));
    AbstractBootDashModel barSpace = harness.createCfTarget(new CFClientParams(apiUrl, username,
            CFCredentials.fromPassword(password), false, "your-org", "bar", false));

    //check the default rendering is like it used to be before introducing templates.
    assertEquals("my-org : foo - [http://api.some-cloud.com]", fooSpace.getDisplayName());
    assertEquals("your-org : bar - [http://api.some-cloud.com]", barSpace.getDisplayName());

    RunTargetType targetType = fooSpace.getRunTarget().getType();

    //Let's try switching the order of org and space
    targetType.setNameTemplate("%s - %o @ %a");
    assertEquals("foo - my-org @ http://api.some-cloud.com", fooSpace.getDisplayName());
    assertEquals("bar - your-org @ http://api.some-cloud.com", barSpace.getDisplayName());

    //Let's try adding 'username' into the label
    targetType.setNameTemplate("%u@%s");
    assertEquals("freddy@foo", fooSpace.getDisplayName());
    assertEquals("freddy@bar", barSpace.getDisplayName());
}