use of org.jboss.tools.openshift.internal.ui.wizard.newapp.ResourceDetailsContentProvider.ResourceProperty in project jbosstools-openshift by jbosstools.
the class ResourceDetailsLabelProviderTest method getStyledTextWithUnkownParameterInMap.
@Test
public void getStyledTextWithUnkownParameterInMap() {
ResourceProperty resourceProperty = mock(ResourceProperty.class);
when(resourceProperty.getProperty()).thenReturn("Prop");
Map<String, String> params = new TreeMap<>();
params.put("${name}", "is name");
params.put("surname", "${surname}");
params.put("gender", "${gender}");
when(resourceProperty.getValue()).thenReturn(params);
assertEquals("Prop: Dmitrii=is name,gender=(Unknown parameter gender),surname=Bocharov", labelsProvider.getStyledText(resourceProperty).toString());
}
use of org.jboss.tools.openshift.internal.ui.wizard.newapp.ResourceDetailsContentProvider.ResourceProperty in project jbosstools-openshift by jbosstools.
the class ResourceDetailsContentProviderTest method shouldReturnUnknownResourcePropertyGivenBuildConfigBuildStrategyIsNull.
@Test
public void shouldReturnUnknownResourcePropertyGivenBuildConfigBuildStrategyIsNull() {
// given
IBuildConfig bc = ResourceMocks.createBuildConfig("42", null, null, null, null, null, null, null);
// when
Object[] children = contentProvider.getChildren(bc);
// then
ResourceProperty property = getResourceProperty(ResourceDetailsContentProvider.LABEL_STRATEGY, children);
assertThat(property).isNotNull();
assertThat(property.isUnknownValue()).isTrue();
}
use of org.jboss.tools.openshift.internal.ui.wizard.newapp.ResourceDetailsContentProvider.ResourceProperty in project jbosstools-openshift by jbosstools.
the class ResourceDetailsLabelProvider method getStyledText.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public StyledString getStyledText(Object element) {
if (element instanceof IResource) {
IResource resource = (IResource) element;
StyledString text = new StyledString(StringUtils.capitalize(resource.getKind()));
text.append(" ").append(replaceParameters(resource.getName()), StyledString.QUALIFIER_STYLER);
return text;
}
if (element instanceof ResourceProperty) {
ResourceProperty property = (ResourceProperty) element;
StyledString text = new StyledString(StringUtils.capitalize(property.getProperty()));
text.append(": ");
String value = null;
if (property.getValue() instanceof Map) {
value = org.jboss.tools.openshift.common.core.utils.StringUtils.serialize((Map) property.getValue());
} else if (property.getValue() instanceof Collection) {
value = StringUtils.join((Collection) property.getValue(), ", ");
} else {
value = property.getValue() != null ? property.getValue().toString() : "";
}
if (StringUtils.isBlank(value)) {
if (property.isUnknownValue()) {
value = LABEL_UNKNOWN;
} else {
value = LABEL_NOT_PROVIDED;
}
}
text.append(replaceParameters(value), StyledString.QUALIFIER_STYLER);
return text;
}
return null;
}
use of org.jboss.tools.openshift.internal.ui.wizard.newapp.ResourceDetailsContentProvider.ResourceProperty in project jbosstools-openshift by jbosstools.
the class ResourceDetailsLabelProviderTest method getStyledTextWithUnknownLabel.
@Test
public void getStyledTextWithUnknownLabel() {
ResourceProperty resourceProperty = mock(ResourceProperty.class);
when(resourceProperty.getProperty()).thenReturn("prop1");
when(resourceProperty.isUnknownValue()).thenReturn(true);
when(resourceProperty.getValue()).thenReturn("");
assertEquals("Prop1: (Unknown)", labelsProvider.getStyledText(resourceProperty).toString());
}
Aggregations