public class ConfigImplTest {
+ private static final String CONFIG_TYPE = "transformation";
+
private static interface MyType extends Identifiable {
}
private static class MyTypeWrapper implements MyType {
+ private String prefix;
private MyType type;
- public MyTypeWrapper(MyType aType) {
+ public MyTypeWrapper(String aPrefix, MyType aType) {
+ prefix = aPrefix;
type = aType;
}
@Override
public Id getId() {
- return type.getId();
+ return new Id(prefix + type.getId().getId());
}
}
@Before
public void setUp() {
sequence = new AtomicLong(1L);
- config = new ConfigImpl<MyType>(new Id<Config>("mytype")) {
+ config = new ConfigImpl<MyType>(new Id<Config>(CONFIG_TYPE)) {
@Override
- public MyType wrap(MyType aT) {
- return new MyTypeWrapper(aT);
+ public MyType wrap(String aPrefix, MyType aT) {
+ return new MyTypeWrapper(aPrefix, aT);
}
};
}
assertEquals(1, config.values().size());
assertTrue(config.values().get(0) instanceof MyTypeWrapper);
assertSame(type1, ((MyTypeWrapper) config.values().get(0)).getType());
+ assertEquals(CONFIG_TYPE + "." + type1.getId().getId(), config.values()
+ .get(0).getId().getId());
// add another one.
MyType type2 = mock(MyType.class);
assertEquals(1, config.values().size());
- assertTrue(config.remove(new Id("type1")));
+ assertTrue(config.remove(new Id(CONFIG_TYPE + "." + "type1")));
assertTrue(config.values().isEmpty());
}