Search in sources :

Example 21 with Pair

use of com.yahoo.collections.Pair in project vespa by vespa-engine.

the class SchemaMappingAndAccessesTest method testProxyAndSecureSecureFailing.

public void testProxyAndSecureSecureFailing() {
    DocumentProcessor procInsecure = new TestDPInsecure();
    Map<Pair<String, String>, String> fieldMap = new HashMap<>();
    fieldMap.put(new Pair<>("album", "titleMapped"), "title");
    procInsecure.setFieldMap(fieldMap);
    DocumentPut put = new DocumentPut(getDoc());
    Document doc = new Call(procInsecure).configDoc(procInsecure, put).getDocument();
    try {
        procInsecure.process(Processing.of(new DocumentPut(doc)));
        fail("Insecure docproc went through");
    } catch (Exception e) {
        assertTrue(e.getMessage().matches(".*allowed.*"));
    }
// assertEquals(doc.get("title"), "MyTitle");
}
Also used : Call(com.yahoo.docproc.Call) DocumentProcessor(com.yahoo.docproc.DocumentProcessor) HashMap(java.util.HashMap) DocumentPut(com.yahoo.document.DocumentPut) Document(com.yahoo.document.Document) Pair(com.yahoo.collections.Pair)

Example 22 with Pair

use of com.yahoo.collections.Pair in project vespa by vespa-engine.

the class SchemaMappingAndAccessesTest method testSchemaMapNoDocType.

public void testSchemaMapNoDocType() {
    SchemaMap map = new SchemaMap(null);
    map.addMapping("mychain", "com.yahoo.MyDocProc", null, "inDoc1", "inProc1");
    map.addMapping("mychain", "com.yahoo.MyDocProc", null, "inDoc2", "inProc2");
    Map<Pair<String, String>, String> cMap = map.chainMap("mychain", "com.yahoo.MyDocProc");
    DocumentProcessor proc = new TestDocumentProcessor1();
    proc.setFieldMap(cMap);
    Map<String, String> dMap = proc.getDocMap("mydoctype");
    assertEquals("inDoc1", dMap.get("inProc1"));
    assertEquals("inDoc2", dMap.get("inProc2"));
}
Also used : DocumentProcessor(com.yahoo.docproc.DocumentProcessor) TestDocumentProcessor1(com.yahoo.docproc.DocumentProcessingAbstractTestCase.TestDocumentProcessor1) Pair(com.yahoo.collections.Pair)

Example 23 with Pair

use of com.yahoo.collections.Pair in project vespa by vespa-engine.

the class DocumentProcessingHandlerForkTestCase method getCallStacks.

@Override
protected List<Pair<String, CallStack>> getCallStacks() {
    ArrayList<Pair<String, CallStack>> stacks = new ArrayList<>(5);
    stacks.add(new Pair<>(TOMANYALLINSAMEBUCKET, new CallStack().addLast(new OneToManyDocumentsAllInSameBucketProcessor())));
    stacks.add(new Pair<>(TOMANYSOMEINSAMEBUCKET, new CallStack().addLast(new OneToManyDocumentsSomeInSameBucketProcessor())));
    stacks.add(new Pair<>(TOMANY, new CallStack().addLast(new OneToManyDocumentsProcessor())));
    stacks.add(new Pair<>(TOONE, new CallStack().addLast(new OneToOneDocumentsProcessor())));
    stacks.add(new Pair<>(TOZERO, new CallStack().addLast(new OneToZeroDocumentsProcessor())));
    return stacks;
}
Also used : CallStack(com.yahoo.docproc.CallStack) Pair(com.yahoo.collections.Pair)

Example 24 with Pair

use of com.yahoo.collections.Pair in project vespa by vespa-engine.

the class DocumentProcessingHandlerTransformingMessagesTestCase method getCallStacks.

@Override
public List<Pair<String, CallStack>> getCallStacks() {
    CallStack stack = new CallStack();
    stack.addLast(new TransformingDocumentProcessor());
    ArrayList<Pair<String, CallStack>> stacks = new ArrayList<>(1);
    stacks.add(new Pair<>(FOOBAR, stack));
    return stacks;
}
Also used : CallStack(com.yahoo.docproc.CallStack) ArrayList(java.util.ArrayList) Pair(com.yahoo.collections.Pair)

Example 25 with Pair

use of com.yahoo.collections.Pair in project vespa by vespa-engine.

the class DocumentProcessingHandlerBasicTestCase method getCallStacks.

@Override
public List<Pair<String, CallStack>> getCallStacks() {
    CallStack stack = new CallStack();
    stack.addLast(new TestDocumentProcessor());
    ArrayList<Pair<String, CallStack>> stacks = new ArrayList<>(1);
    stacks.add(new Pair<>("foobar", stack));
    return stacks;
}
Also used : CallStack(com.yahoo.docproc.CallStack) ArrayList(java.util.ArrayList) Pair(com.yahoo.collections.Pair)

Aggregations

Pair (com.yahoo.collections.Pair)29 Test (org.junit.Test)9 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)8 AttributeFields (com.yahoo.searchdefinition.derived.AttributeFields)8 RawRankProfile (com.yahoo.searchdefinition.derived.RawRankProfile)8 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 CallStack (com.yahoo.docproc.CallStack)5 DocumentProcessor (com.yahoo.docproc.DocumentProcessor)4 Call (com.yahoo.docproc.Call)2 TestDocumentProcessor1 (com.yahoo.docproc.DocumentProcessingAbstractTestCase.TestDocumentProcessor1)2 Document (com.yahoo.document.Document)2 DocumentPut (com.yahoo.document.DocumentPut)2 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)2 SimpleLinguistics (com.yahoo.language.simple.SimpleLinguistics)2 IOException (java.io.IOException)2 URI (java.net.URI)2 Collections (java.util.Collections)2 List (java.util.List)2 Map (java.util.Map)2