Permalink
Browse files

Added a convenience test to see if a parameter has been registered to…

… the model
  • Loading branch information...
egonw committed Jun 5, 2011
1 parent 7bfb28b commit ad04b69818bd10bee7d85996154164baf7145966
@@ -375,6 +375,16 @@ public void setNotification(boolean notification) {
}
/**
* Returns true if the passed {@link IGeneratorParameter}s has been
* registered.
*
* @return boolean indicating the parameters is registered
*/
public <T extends IGeneratorParameter<?>> boolean hasParameter(Class<T> param) {
return renderingParameters.containsKey(param.getName());
}
/**
* Returns the {@link IGeneratorParameter} for the active {@link IRenderer}.
* It returns a new instance of it was unregistered.
*
@@ -74,6 +74,33 @@ public IRenderingElement generate(IChemObject object,
);
}
@Test
public void testHasParameter() {
IGenerator<IChemObject> generator = new IGenerator<IChemObject>() {
IGeneratorParameter<Boolean> someParam = new SomeParam();
@Override
public List<IGeneratorParameter<?>> getParameters() {
return new ArrayList<IGeneratorParameter<?>>() {{
add(someParam);
}};
}
@Override
public IRenderingElement generate(IChemObject object,
RendererModel model) {
// TODO Auto-generated method stub
return null;
}
};
RendererModel model = new RendererModel();
Assert.assertFalse(
model.hasParameter(SomeParam.class)
);
model.registerParameters(generator);
Assert.assertTrue(
model.hasParameter(SomeParam.class)
);
}
@Test
public void testReturningTheRealParamaterValue() {
IGenerator<IChemObject> generator = new IGenerator<IChemObject>() {

0 comments on commit ad04b69

Please sign in to comment.