Search in sources :

Example 11 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class GlobalDistributionValidatorTest method throws_exception_on_unknown_document.

@Test
public void throws_exception_on_unknown_document() {
    NewDocumentType unknown = new NewDocumentType(new NewDocumentType.Name("unknown"));
    NewDocumentType child = createDocumentType("child", unknown);
    Fixture fixture = new Fixture().addNonGlobalDocument(child);
    Redundancy redundancy = createRedundancyWithGlobalDistribution();
    exceptionRule.expect(IllegalArgumentException.class);
    exceptionRule.expectMessage("The following document types are referenced from other documents, but are not listed in services.xml: 'unknown'");
    validate(fixture, redundancy);
}
Also used : NewDocumentType(com.yahoo.documentmodel.NewDocumentType) Test(org.junit.Test)

Example 12 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class GlobalDistributionValidatorTest method throws_exception_if_referenced_document_not_global.

@Test
public void throws_exception_if_referenced_document_not_global() {
    NewDocumentType parent = createDocumentType("parent");
    Fixture fixture = new Fixture().addNonGlobalDocument(parent).addNonGlobalDocument(createDocumentType("child", parent));
    Redundancy redundancy = createRedundancyWithoutGlobalDistribution();
    exceptionRule.expect(IllegalArgumentException.class);
    exceptionRule.expectMessage("The following document types are referenced from other documents, but are not globally distributed: 'parent'");
    validate(fixture, redundancy);
}
Also used : NewDocumentType(com.yahoo.documentmodel.NewDocumentType) Test(org.junit.Test)

Example 13 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class IndexedTest method requireMultipleDocumentTypes.

@Test
public void requireMultipleDocumentTypes() {
    VespaModelCreatorWithMockPkg creator = getIndexedVespaModelCreator();
    VespaModel model = creator.create();
    DeployState deployState = creator.deployState;
    IndexedSearchCluster cluster = model.getContentClusters().get("test").getSearch().getIndexed();
    assertEquals(3, cluster.getDocumentDbs().size());
    NewDocumentType type1 = deployState.getDocumentModel().getDocumentManager().getDocumentType("type1");
    NewDocumentType type2 = deployState.getDocumentModel().getDocumentManager().getDocumentType("type2");
    NewDocumentType type3 = deployState.getDocumentModel().getDocumentManager().getDocumentType("type3");
    assertNotNull(type1);
    assertNotNull(type2);
    assertNotNull(type3);
}
Also used : IndexedSearchCluster(com.yahoo.vespa.model.search.IndexedSearchCluster) VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) DeployState(com.yahoo.config.model.deploy.DeployState) VespaModel(com.yahoo.vespa.model.VespaModel) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) Test(org.junit.Test)

Example 14 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class StorageClusterTest method requireThatUserDoesNotSpecifyBothGroupAndNodes.

@Test
public void requireThatUserDoesNotSpecifyBothGroupAndNodes() throws Exception {
    String xml = "<cluster id=\"storage\">\n" + "<documents/>\n" + "<engine>\n" + "    <fail-partition-on-error>true</fail-partition-on-error>\n" + "    <revert-time>34m</revert-time>\n" + "    <recovery-time>5d</recovery-time>\n" + "</engine>" + "  <group>\n" + "    <node distribution-key=\"0\" hostalias=\"mockhost\"/>\n" + "  </group>\n" + "  <nodes>\n" + "    <node distribution-key=\"1\" hostalias=\"mockhost\"/>\n" + "  </nodes>\n" + "</cluster>";
    try {
        final MockRoot root = new MockRoot();
        root.getDeployState().getDocumentModel().getDocumentManager().add(new NewDocumentType(new NewDocumentType.Name("music")));
        ContentClusterUtils.createCluster(xml, root);
        fail("Did not fail when having both group and nodes");
    } catch (RuntimeException e) {
        e.printStackTrace();
        assertEquals("Both group and nodes exists, only one of these tags is legal", e.getMessage());
    }
}
Also used : MockRoot(com.yahoo.config.model.test.MockRoot) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) Test(org.junit.Test)

Example 15 with NewDocumentType

use of com.yahoo.documentmodel.NewDocumentType in project vespa by vespa-engine.

the class DocumentGenMojo method execute.

void execute(File sdDir, File outputDir, String packageName) throws MojoFailureException {
    if ("".equals(packageName))
        throw new IllegalArgumentException("You may not use empty package for generated types.");
    searches = new HashMap<String, Search>();
    docTypes = new HashMap<String, String>();
    structTypes = new HashMap<String, String>();
    annotationTypes = new HashMap<String, String>();
    outputDir.mkdirs();
    SearchBuilder builder = buildSearches(sdDir);
    boolean annotationsExported = false;
    for (NewDocumentType docType : builder.getModel().getDocumentManager().getTypes()) {
        if (docType != VespaDocumentType.INSTANCE) {
            exportDocumentSources(outputDir, docType, packageName);
            for (AnnotationType annotationType : docType.getAllAnnotations()) {
                if (provided(annotationType.getName()) != null)
                    continue;
                annotationsExported = true;
                exportAnnotationSources(outputDir, annotationType, docType, packageName);
            }
        }
    }
    exportPackageInfo(outputDir, packageName);
    if (annotationsExported)
        exportPackageInfo(outputDir, packageName + ".annotation");
    exportDocFactory(outputDir, builder.getSearchList(), packageName);
    if (project != null)
        project.addCompileSourceRoot(outputDirectory.toString());
}
Also used : Search(com.yahoo.searchdefinition.Search) UnprocessingSearchBuilder(com.yahoo.searchdefinition.UnprocessingSearchBuilder) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) AnnotationType(com.yahoo.document.annotation.AnnotationType)

Aggregations

NewDocumentType (com.yahoo.documentmodel.NewDocumentType)23 Test (org.junit.Test)7 StructDataType (com.yahoo.document.StructDataType)4 AnnotationReferenceDataType (com.yahoo.document.annotation.AnnotationReferenceDataType)4 ReferenceDataType (com.yahoo.document.ReferenceDataType)3 AnnotationType (com.yahoo.document.annotation.AnnotationType)3 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)3 MockRoot (com.yahoo.config.model.test.MockRoot)2 CollectionDataType (com.yahoo.document.CollectionDataType)2 DocumentType (com.yahoo.document.DocumentType)2 Field (com.yahoo.document.Field)2 MapDataType (com.yahoo.document.MapDataType)2 VespaDocumentType (com.yahoo.documentmodel.VespaDocumentType)2 TemporaryAnnotationReferenceDataType (com.yahoo.searchdefinition.document.annotation.TemporaryAnnotationReferenceDataType)2 ModelElement (com.yahoo.vespa.model.builder.xml.dom.ModelElement)2 HashSet (java.util.HashSet)2 DeployState (com.yahoo.config.model.deploy.DeployState)1 com.yahoo.document (com.yahoo.document)1 DataType (com.yahoo.document.DataType)1 StructuredDataType (com.yahoo.document.StructuredDataType)1