List of usage examples for org.springframework.ide.eclipse.boot.dash.views CustomizeTargetLabelDialogModel create
public static EditTemplateDialogModel create(final BootDashModel section)
From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java
@Test public void customizeTargetLabelDialog() throws Exception { EditTemplateDialogModel dialog;/*from ww w .ja v a2s. co m*/ 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)); ModelStateListener modelStateListener = mock(ModelStateListener.class); fooSpace.addModelStateListener(modelStateListener); barSpace.addModelStateListener(modelStateListener); // Check initial state of the dialog when no custom labels have yet been set at all: dialog = CustomizeTargetLabelDialogModel.create(fooSpace); assertTrue(dialog.applyToAll.getValue()); assertEquals("%o : %s - [%a]", dialog.template.getValue()); //Check performOk only changes the one label when 'apply to all' is disabled. dialog.applyToAll.setValue(false); dialog.template.setValue("CHANGED %s -> %o"); dialog.performOk(); verify(modelStateListener).stateChanged(same(fooSpace)); verify(modelStateListener, never()).stateChanged(same(barSpace)); assertEquals("CHANGED foo -> my-org", fooSpace.getDisplayName()); assertEquals("your-org : bar - [http://api.some-cloud.com]", barSpace.getDisplayName()); //Opening the dialog now should have 'apply to all' disabled to avoid accidentally overwriting // existing individually customized labels... dialog = CustomizeTargetLabelDialogModel.create(fooSpace); assertFalse(dialog.applyToAll.getValue()); assertEquals("CHANGED %s -> %o", dialog.template.getValue()); //Also if we open the dialog on the other element!!! dialog = CustomizeTargetLabelDialogModel.create(barSpace); assertFalse(dialog.applyToAll.getValue()); assertEquals("%o : %s - [%a]", dialog.template.getValue()); //Selecting 'apply to all' should set the template on the type and erase custom templates on the // individual targets. dialog.applyToAll.setValue(true); dialog.template.setValue("DIFFERENT %s -> %o"); dialog.performOk(); assertEquals("DIFFERENT %s -> %o", harness.getCfTargetType().getNameTemplate()); for (BootDashModel target : harness.getCfRunTargetModels()) { assertFalse(target.hasCustomNameTemplate()); assertEquals("DIFFERENT %s -> %o", target.getNameTemplate()); } assertEquals("DIFFERENT foo -> my-org", fooSpace.getDisplayName()); assertEquals("DIFFERENT bar -> your-org", barSpace.getDisplayName()); }