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

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

            DocumentUpdate output = (DocumentUpdate)tester.process(input);
            assertEquals(4, output.fieldUpdates().size());
            tester.assertAssignment("artist", "artist1", output);
            tester.assertAssignment("title", "title1", output);
            tester.assertAssignment("combined", "artist1 title1", output);
            tester.assertAssignment("combinedWithFallback", "artist1 title1", output);
        }

        {   // Just artist is set
            DocumentType inputType = tester.getDocumentType("music");
            DocumentUpdate input = new DocumentUpdate(inputType, "id:ns:music::");
            input.addFieldUpdate(FieldUpdate.createAssign(inputType.getField("artist"), new StringFieldValue("artist1")));

            DocumentUpdate output = (DocumentUpdate)tester.process(input);
            assertEquals(2, output.fieldUpdates().size());
            tester.assertAssignment("artist", "artist1", output);
            tester.assertAssignment("combinedWithFallback", "artist1 ", output);
        }

        {   // Just title is set
            DocumentType inputType = tester.getDocumentType("music");
            DocumentUpdate input = new DocumentUpdate(inputType, "id:ns:music::");
            input.addFieldUpdate(FieldUpdate.createAssign(inputType.getField("title"), new StringFieldValue("title1")));

            DocumentUpdate output = (DocumentUpdate)tester.process(input);
            assertEquals(2, output.fieldUpdates().size());
            tester.assertAssignment("title", "title1", output);
            tester.assertAssignment("combinedWithFallback", " title1", output);
        }

        {   // Neither title nor artist is set: Should not update embeddings even though it has fallbacks for all
            DocumentType inputType = tester.getDocumentType("music");
            DocumentUpdate input = new DocumentUpdate(inputType, "id:ns:music::");
            input.addFieldUpdate(FieldUpdate.createAssign(inputType.getField("song"), new StringFieldValue("song1")));

            DocumentUpdate output = (DocumentUpdate)tester.process(input);
            assertEquals(1, output.fieldUpdates().size());
            tester.assertAssignment("song", "song1", output);
        }

        {   // None is set: Should not update anything
            DocumentType inputType = tester.getDocumentType("music");
            DocumentUpdate input = new DocumentUpdate(inputType, "id:ns:music::");

            DocumentUpdate output = (DocumentUpdate)tester.process(input);
            assertNull(output);
        }

        {   // Clear title by assigning null: Embedding is kept (not very clear what's the best action).
            DocumentType inputType = tester.getDocumentType("music");
            DocumentUpdate input = new DocumentUpdate(inputType, "id:ns:music::");
            input.addFieldUpdate(FieldUpdate.createClear(inputType.getField("title")));

            DocumentUpdate output = (DocumentUpdate)tester.process(input);
            assertEquals(1, output.fieldUpdates().size());
            tester.assertAssignment("title", null, output);
        }
    }
@author Simon Thoresen Hult
@author bratseth
docprocs/src/test/java/com/yahoo/docprocs/indexing/IndexingProcessorTestCase.java