RGBImageProfile implements ConfigurableExtension { public void configure(ConfigurationElement config) throws CoreException { name = getChildValue(config, "name"); internal = true; rgbaExpressions[R] = getChildValue(config, "red"); rgbaExpressions[G] = getChildValue(config, "green"); rgbaExpressions[B] = getChildValue(config, "blue"); ConfigurationElement child = config.getChild("alpha"); String alpha = null; if (child != null) { alpha = child.getValue(); } if (alpha == null) { alpha = ""; } rgbaExpressions[A] = alpha; ConfigurationElement patternConfig = config.getChild("pattern"); if (patternConfig != null) { pattern = new String[3]; ConfigurationElement productType = patternConfig.getChild("productType"); ConfigurationElement productName = patternConfig.getChild("productName"); ConfigurationElement productDesc = patternConfig.getChild("productDesc"); if (productType != null) { pattern[0] = productType.getValue(); } if (productName != null) { pattern[1] = productName.getValue(); } if (productDesc != null) { pattern[2] = productDesc.getValue(); } } } RGBImageProfile();  RGBImageProfile(final String name);  RGBImageProfile(final String name, String[] rgbaExpressions);  RGBImageProfile(final String name, String[] rgbaExpressions, String pattern[]); String getName(); void setName(String name); boolean isInternal(); void setInternal(final boolean internal); boolean equalExpressions(RGBImageProfile profile); boolean equalExpressions(String[] rgbaExpressions); boolean isValid(); String[] getRgbExpressions(); void setRgbExpressions(String[] rgbExpressions); String[] getRgbaExpressions(); void setRgbaExpressions(String[] rgbaExpressions); String getRedExpression(); void setRedExpression(String expression); String getGreenExpression(); void setGreenExpression(String expression); String getBlueExpression(); void setBlueExpression(String expression); String getAlphaExpression(); void setAlphaExpression(String expression); boolean hasAlpha(); String[] getPattern(); void setPattern(String[] pattern); boolean isApplicableTo(final Product product); static RGBImageProfile getCurrentProfile(final Product product); static RGBImageProfile loadProfile(final File file); static RGBImageProfile loadProfile(final URL url); void store(final File file); void getProperties(final Properties properties); @SuppressWarnings("LocalVariableHidesMemberVariable") void setProperties(Properties properties); static void storeRgbaExpressions(final Product product, final String[] rgbaExpressions); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); void configure(ConfigurationElement config); static final String RED_BAND_NAME; static final String GREEN_BAND_NAME; static final String BLUE_BAND_NAME; static final String ALPHA_BAND_NAME; static final String[] RGB_BAND_NAMES; static final String[] RGBA_BAND_NAMES; static final String FILENAME_EXTENSION; static final String PROPERTY_KEY_NAME; static final String PROPERTY_KEY_RED; static final String PROPERTY_KEY_GREEN; static final String PROPERTY_KEY_BLUE; static final String PROPERTY_KEY_ALPHA; static final String PROPERTY_KEY_INTERNAL; final static String PROPERTY_KEY_PREFIX_RGB_PROFILE; }
@Test public void testConfigure() throws Exception { RGBImageProfile profile = new RGBImageProfile(); ConfigurationElement config = mock(ConfigurationElement.class); ConfigurationElement nameConfig = mock(ConfigurationElement.class); ConfigurationElement redConfig = mock(ConfigurationElement.class); ConfigurationElement greenConfig = mock(ConfigurationElement.class); ConfigurationElement blueConfig = mock(ConfigurationElement.class); ConfigurationElement patternConfig = mock(ConfigurationElement.class); ConfigurationElement productTypeConfig = mock(ConfigurationElement.class); ConfigurationElement productNameConfig = mock(ConfigurationElement.class); ConfigurationElement productDescConfig = mock(ConfigurationElement.class); when(nameConfig.getValue()).thenReturn("test_name"); when(redConfig.getValue()).thenReturn("radiance_12"); when(greenConfig.getValue()).thenReturn("radiance_6"); when(blueConfig.getValue()).thenReturn("radiance_2"); when(productTypeConfig.getValue()).thenReturn("MER_*_1*"); when(productNameConfig.getValue()).thenReturn("ATS_*_1*"); when(productDescConfig.getValue()).thenReturn(""); when(config.getChild("name")).thenReturn(nameConfig); when(config.getChild("red")).thenReturn(redConfig); when(config.getChild("green")).thenReturn(greenConfig); when(config.getChild("blue")).thenReturn(blueConfig); when(config.getChild("alpha")).thenReturn(null); when(config.getChild("pattern")).thenReturn(patternConfig); when(patternConfig.getChild("productType")).thenReturn(productTypeConfig); when(patternConfig.getChild("productName")).thenReturn(productNameConfig); when(patternConfig.getChild("productDesc")).thenReturn(productDescConfig); profile.configure(config); assertEquals("test_name", profile.getName()); assertEquals("", profile.getAlphaExpression()); assertEquals("radiance_2", profile.getBlueExpression()); assertEquals("radiance_12", profile.getRedExpression()); assertEquals("radiance_6", profile.getGreenExpression()); assertTrue(Arrays.equals(new String[]{"MER_*_1*", "ATS_*_1*", ""}, profile.getPattern())); }