aboutsummaryrefslogtreecommitdiffstats
path: root/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/RestApiWithTestDocumentHandler.java
blob: 138916f6979430b561de7230bdb102f4209ab857 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.document.restapi.resource;

import com.yahoo.container.logging.AccessLog;
import com.yahoo.document.DataType;
import com.yahoo.document.DocumentType;
import com.yahoo.document.DocumentTypeManager;
import com.yahoo.document.restapi.OperationHandler;

import java.util.concurrent.Executor;

/**
 * For setting up RestApi with a simple document type manager.
 *
 * @author dybis
 */
public class RestApiWithTestDocumentHandler extends RestApi{

    private DocumentTypeManager docTypeManager = new DocumentTypeManager();

    public RestApiWithTestDocumentHandler(
            Executor executor,
            AccessLog accessLog,
            OperationHandler operationHandler) {
        super(executor, accessLog, operationHandler, 20);

        DocumentType documentType = new DocumentType("testdocument");

        documentType.addField("title", DataType.STRING);
        documentType.addField("body", DataType.STRING);
        docTypeManager.registerDocumentType(documentType);

        setDocTypeManagerForTests(docTypeManager);
    }

}