Example usage for org.springframework.ide.eclipse.boot.dash.model.runtargettypes RunTargetType setNameTemplate

List of usage examples for org.springframework.ide.eclipse.boot.dash.model.runtargettypes RunTargetType setNameTemplate

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.boot.dash.model.runtargettypes RunTargetType setNameTemplate.

Prototype

void setNameTemplate(String string) throws Exception;

Source Link

Document

Sets a persistent property that overrides the default name template.

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());
}