@Test
    public void testPut() {
        IndexingProcessorTester tester = new IndexingProcessorTester("src/test/cfg");
        // 'combined' gets the value of both
        // 'combinedWithFallback' falls back to an empty string if an input is missing

        {   // Both artist and title are set
            DocumentType inputType = tester.getDocumentType("music");
            DocumentPut input = new DocumentPut(inputType, "id:ns:music::");
            input.getDocument().setFieldValue(inputType.getField("artist"), new StringFieldValue("artist1"));
            input.getDocument().setFieldValue(inputType.getField("title"), new StringFieldValue("title1"));

            Document output = ((DocumentPut)tester.process(input)).getDocument();
            assertEquals("artist1", output.getFieldValue("artist").getWrappedValue());
            assertEquals("title1", output.getFieldValue("title").getWrappedValue());
            assertNull(output.getFieldValue("song"));
            assertEquals("artist1 title1", output.getFieldValue("combined").getWrappedValue());
            assertEquals("artist1 title1", output.getFieldValue("combinedWithFallback").getWrappedValue());
        }

        {   // Just artist is set
            DocumentType inputType = tester.getDocumentType("music");
            DocumentPut input = new DocumentPut(inputType, "id:ns:music::");
            input.getDocument().setFieldValue(inputType.getField("artist"), new StringFieldValue("artist1"));

            Document output = ((DocumentPut)tester.process(input)).getDocument();
            assertEquals("artist1", output.getFieldValue("artist").getWrappedValue());
            assertNull(output.getFieldValue("title"));
            assertNull(output.getFieldValue("song"));
            assertNull(output.getFieldValue("combined"));
            assertEquals("artist1 ", output.getFieldValue("combinedWithFallback").getWrappedValue());
        }

        {   // Just title is set
            DocumentType inputType = tester.getDocumentType("music");
            DocumentPut input = new DocumentPut(inputType, "id:ns:music::");
            input.getDocument().setFieldValue(inputType.getField("title"), new StringFieldValue("title1"));

            Document output = ((DocumentPut)tester.process(input)).getDocument();
            assertEquals("title1", output.getFieldValue("title").getWrappedValue());
            assertNull(output.getFieldValue("artist"));
            assertNull(output.getFieldValue("song"));
            assertNull(output.getFieldValue("combined"));
            assertEquals(" title1", output.getFieldValue("combinedWithFallback").getWrappedValue());
        }

        {   // Neither title nor artist is set
            DocumentType inputType = tester.getDocumentType("music");
            DocumentPut input = new DocumentPut(inputType, "id:ns:music::");
            input.getDocument().setFieldValue(inputType.getField("song"), new StringFieldValue("song1"));

            Document output = ((DocumentPut)tester.process(input)).getDocument();
            assertNull(output.getFieldValue("artist"));
            assertNull(output.getFieldValue("title"));
            assertEquals("song1", output.getFieldValue("song").getWrappedValue());
            assertNull(output.getFieldValue("combined"));
            assertEquals(" ", output.getFieldValue("combinedWithFallback").getWrappedValue());
        }

        {   // None is set
            DocumentType inputType = tester.getDocumentType("music");
            DocumentPut input = new DocumentPut(inputType, "id:ns:music::");

            Document output = ((DocumentPut)tester.process(input)).getDocument();
            assertNull(output.getFieldValue("artist"));
            assertNull(output.getFieldValue("title"));
            assertNull(output.getFieldValue("song"));
            assertNull(output.getFieldValue("combined"));
            assertEquals(" ", output.getFieldValue("combinedWithFallback").getWrappedValue());
        }
    }
@author Simon Thoresen Hult
@author bratseth
docprocs/src/test/java/com/yahoo/docprocs/indexing/IndexingProcessorTestCase.java