use of com.yahoo.component.Version 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.Version 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());
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class VespaModelCreatorWithFilePkg method validate.
public void validate() throws IOException {
ApplicationPackageXmlFilesValidator validator = ApplicationPackageXmlFilesValidator.create(applicationPkg.getAppDir(), new Version(6));
validator.checkApplication();
validator.checkIncludedDirs(applicationPkg);
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class PrepareParamsTest method testCorrectParsingWithRotation.
@Test
public void testCorrectParsingWithRotation() {
PrepareParams prepareParams = createParams(request + "&" + PrepareParams.ROTATIONS_PARAM_NAME + "=" + rotation, TenantName.from("foo"));
assertThat(prepareParams.getApplicationId().serializedForm(), is("foo:baz:default"));
assertTrue(prepareParams.isDryRun());
assertTrue(prepareParams.isVerbose());
assertFalse(prepareParams.ignoreValidationErrors());
Version expectedVersion = Version.fromString(vespaVersion);
assertThat(prepareParams.vespaVersion().get(), is(expectedVersion));
assertTrue(prepareParams.getTimeoutBudget().hasTimeLeft());
Set<Rotation> rotations = prepareParams.rotations();
assertThat(rotations.size(), is(1));
assertThat(rotations, contains(equalTo(new Rotation(rotation))));
}
use of com.yahoo.component.Version in project vespa by vespa-engine.
the class ModelContextImplTest method testModelContextTest.
@Test
public void testModelContextTest() {
final Rotation rotation = new Rotation("this.is.a.mock.rotation");
final Set<Rotation> rotations = Collections.singleton(rotation);
ModelContext context = new ModelContextImpl(MockApplicationPackage.createEmpty(), Optional.empty(), Optional.empty(), new BaseDeployLogger(), new StaticConfigDefinitionRepo(), new MockFileRegistry(), Optional.empty(), new ModelContextImpl.Properties(ApplicationId.defaultId(), true, Collections.emptyList(), null, false, Zone.defaultZone(), rotations), Optional.empty(), new Version(6), new Version(6));
assertTrue(context.applicationPackage() instanceof MockApplicationPackage);
assertFalse(context.hostProvisioner().isPresent());
assertFalse(context.permanentApplicationPackage().isPresent());
assertFalse(context.previousModel().isPresent());
assertTrue(context.getFileRegistry() instanceof MockFileRegistry);
assertTrue(context.configDefinitionRepo() instanceof StaticConfigDefinitionRepo);
assertThat(context.properties().applicationId(), is(ApplicationId.defaultId()));
assertTrue(context.properties().configServerSpecs().isEmpty());
assertTrue(context.properties().multitenant());
assertTrue(context.properties().zone() instanceof Zone);
assertFalse(context.properties().hostedVespa());
assertThat(context.properties().rotations(), equalTo(rotations));
}
Aggregations