use of com.yahoo.config.model.test.MockRoot in project vespa by vespa-engine.
the class FileSenderTest method setup.
@Before
public void setup() {
MockRoot root = new MockRoot();
producer = new SimpleConfigProducer<>(root, "test");
service = new TestService(root, "service");
serviceList = new ArrayList<>();
serviceList.add(service);
ConfigDefinitionKey key = new ConfigDefinitionKey("myname", "mynamespace");
def = new ConfigDefinition("myname", "1", "mynamespace");
builder = new ConfigPayloadBuilder(def);
Map<ConfigDefinitionKey, ConfigPayloadBuilder> builderMap = new HashMap<>();
builderMap.put(key, builder);
UserConfigRepo testRepo = new UserConfigRepo(builderMap);
producer.setUserConfigs(testRepo);
}
use of com.yahoo.config.model.test.MockRoot in project vespa by vespa-engine.
the class ModelGraphTest method require_that_instance_can_be_created.
@Test
public void require_that_instance_can_be_created() {
ModelGraph graph = new ModelGraphBuilder().addBuilder(new GraphMock.BC()).addBuilder(new GraphMock.BB()).addBuilder(new GraphMock.BA()).build();
List<ModelNode> nodes = graph.topologicalSort();
MockRoot root = new MockRoot();
GraphMock.A a = (GraphMock.A) nodes.get(0).createModel(ConfigModelContext.create(null, root, "first"));
GraphMock.B b = (GraphMock.B) nodes.get(1).createModel(ConfigModelContext.create(null, root, "second"));
GraphMock.B b2 = (GraphMock.B) nodes.get(1).createModel(ConfigModelContext.create(null, root, "second2"));
GraphMock.C c = (GraphMock.C) nodes.get(2).createModel(ConfigModelContext.create(null, root, "third"));
assertNotNull(a);
assertNotNull(b);
assertNotNull(b2);
assertNotNull(c);
assertThat(a.getId(), is("first"));
assertThat(b.getId(), is("second"));
assertThat(b2.getId(), is("second2"));
assertThat(c.getId(), is("third"));
assertThat(b.a, is(a));
assertNotNull(c.b);
assertThat(c.b.size(), is(2));
assertTrue(c.b.contains(b));
assertTrue(c.b.contains(b2));
}
use of com.yahoo.config.model.test.MockRoot in project vespa by vespa-engine.
the class DomSearchChainsBuilderTest method referToFederationAsSearcher.
@Test
public void referToFederationAsSearcher() {
final Element element = parse("<searchchains>", " <federation id='federationSearcher'>", " <source id='mysource'>", " <federationoptions optional='false' />", " </source>", " </federation>", " <searchchain id='default'>", " <searcher id='federationSearcher'/>", " </searchchain>", "</searchchains>");
try {
new DomSearchChainsBuilder().build(new MockRoot(), element);
fail("Expected exception when referring to an outer 'federation' as a 'searcher'.");
} catch (RuntimeException e) {
assertThat(e.getMessage(), containsString("Two different types declared for the component with name 'federationSearcher'"));
}
}
use of com.yahoo.config.model.test.MockRoot in project vespa by vespa-engine.
the class ConfigValueChangeValidatorTest method requireThatValidatorHandlesModelsWithDifferentTopology.
@Test
public void requireThatValidatorHandlesModelsWithDifferentTopology() {
MockRoot oldRoot = createRootWithChildren(new SimpleConfigProducer("p1", 0).withChildren(new ServiceWithAnnotation("s1", 1)), new SimpleConfigProducer("p2", 0).withChildren(new ServiceWithAnnotation("s2", 1)));
MockRoot newRoot = createRootWithChildren(new ServiceWithAnnotation("s1", 2), new ServiceWithAnnotation("s2", 2), new ServiceWithAnnotation("s3", 2));
List<ConfigChangeAction> changes = getConfigChanges(oldRoot, newRoot);
assertTrue(changes.isEmpty());
assertEmptyLog();
}
use of com.yahoo.config.model.test.MockRoot in project vespa by vespa-engine.
the class ConfigValueChangeValidatorTest method requireThatServicesAnnotatedWithNonRestartConfigProduceWarningInLog.
@Test
public void requireThatServicesAnnotatedWithNonRestartConfigProduceWarningInLog() {
MockRoot root = createRootWithChildren(new NonRestartConfigAnnotatedService(""));
getConfigChanges(root, root);
assertEquals(1, logger.entries.size());
}
Aggregations