use of com.yahoo.component.provider.ComponentClass in project vespa by vespa-engine.
the class ComponentClassTestCase method testCreateComponent.
@SuppressWarnings("unchecked")
@Test
public void testCreateComponent() throws NoSuchMethodException {
Map<ConfigKey, ConfigInstance> availableConfigs = new HashMap<>();
String configId = "testConfigId";
availableConfigs.put(new ConfigKey(StringConfig.class, configId), new StringConfig(new StringConfig.Builder()));
availableConfigs.put(new ConfigKey(IntConfig.class, configId), new IntConfig(new IntConfig.Builder()));
ComponentClass<TestComponent> testClass = new ComponentClass<>(TestComponent.class);
TestComponent component = testClass.createComponent(new ComponentId("test", new Version(1)), availableConfigs, configId);
assertEquals("test", component.getId().getName());
assertEquals(1, component.getId().getVersion().getMajor());
assertEquals(1, component.intVal);
assertEquals("_default_", component.stringVal);
}
use of com.yahoo.component.provider.ComponentClass in project vespa by vespa-engine.
the class ComponentClassTestCase method testNullIdComponent.
/**
* Verifies that ComponentClass sets the ComponentId when a component that takes a ComponentId as
* constructor argument fails to call super(id).
*/
@Test
public void testNullIdComponent() throws NoSuchMethodException {
ComponentClass<NullIdComponent> testClass = new ComponentClass<>(NullIdComponent.class);
NullIdComponent component = testClass.createComponent(new ComponentId("null-test", new Version(1)), new HashMap<ConfigKey, ConfigInstance>(), null);
assertEquals("null-test", component.getId().getName());
assertEquals(1, component.getId().getVersion().getMajor());
}
Aggregations