VespaModelFactory implements ModelFactory { @Override public ModelCreateResult createAndValidateModel(ModelContext modelContext, ValidationParameters validationParameters) { validateXml(modelContext, validationParameters.ignoreValidationErrors()); DeployState deployState = createDeployState(modelContext, validationParameters); VespaModel model = buildModel(deployState); List<ConfigChangeAction> changeActions = validateModel(model, deployState, validationParameters); return new ModelCreateResult(model, changeActions); } @Inject  VespaModelFactory(ComponentRegistry<ConfigModelPlugin> pluginRegistry,
                             ComponentRegistry<MlModelImporter> modelImporters,
                             Zone zone);  VespaModelFactory(ConfigModelRegistry configModelRegistry);  VespaModelFactory(ConfigModelRegistry configModelRegistry, Clock clock);  VespaModelFactory(Version version, ConfigModelRegistry configModelRegistry, Clock clock, Zone zone); @Override Version version(); @Override Model createModel(ModelContext modelContext); @Override ModelCreateResult createAndValidateModel(ModelContext modelContext, ValidationParameters validationParameters);  }
@Test(expected = IllegalArgumentException.class) public void testThatFactoryModelValidationFailsWithIllegalArgumentException() { VespaModelFactory modelFactory = new VespaModelFactory(new NullConfigModelRegistry()); modelFactory.createAndValidateModel(new MockModelContext(createApplicationPackageThatFailsWhenValidating()), new ValidationParameters()); }
@Test(expected = RuntimeException.class) public void testThatFactoryModelValidationFails() { VespaModelFactory modelFactory = new VespaModelFactory(new NullConfigModelRegistry()); modelFactory.createAndValidateModel(testModelContext, new ValidationParameters()); }
@Test public void testThatFactoryModelValidationCanBeIgnored() { VespaModelFactory modelFactory = new VespaModelFactory(new NullConfigModelRegistry()); ModelCreateResult createResult = modelFactory.createAndValidateModel( new MockModelContext(createApplicationPackageThatFailsWhenValidating()), new ValidationParameters(ValidationParameters.IgnoreValidationErrors.TRUE)); assertNotNull(createResult.getModel()); assertNotNull(createResult.getConfigChangeActions()); assertTrue(createResult.getConfigChangeActions().isEmpty()); }