Package com.findwise.hydra.local

Examples of com.findwise.hydra.local.LocalDocument


  public void testProcessExtraFieldNames() throws Exception {
    MergeFieldsStage mfs = new MergeFieldsStage();
    mfs.setOutputField("newfield");
    mfs.setFromFields(Arrays.asList("in1", "in3"));

    LocalDocument doc = getDocument();
    doc.putContentField("out", "xyz");

    LocalDocument doc2 = new LocalDocument(doc);
    mfs.process(doc2);

    String[] newString = doc2.getContentField("newfield").toString().split(" ");
   
    Assert.assertEquals(2, newString.length);
    for(String s : newString) {
      Assert.assertTrue(hasValue(doc, s));
    }
View Full Code Here


  }
 
  @Test(expected = ConversionException.class)
  public void testConversionWithNullCharacterInFieldName() throws ConversionException {
    MongoConnector mdc = mongoConnectorResource.getConnector();
    LocalDocument ld = new LocalDocument();
    ld.putContentField("field\0000name", "field value");
    mdc.convert(ld);
  }
View Full Code Here

  }
 
  @Test(expected = ConversionException.class)
  public void testConversionWithNullCharacterInList() throws ConversionException {
    MongoConnector mdc = mongoConnectorResource.getConnector();
    LocalDocument ld = new LocalDocument();
    ld.putContentField("fieldname", Arrays.asList(new String[] {"some", "string", "with", "null\u0000here"}));
    mdc.convert(ld);
  }
View Full Code Here

  }

  @Test(expected = ConversionException.class)
  public void testConversionWithNullCharacterInString() throws ConversionException {
    MongoConnector mdc = mongoConnectorResource.getConnector();
    LocalDocument ld = new LocalDocument();
    ld.putContentField("fieldname", "some\u0000null");
    mdc.convert(ld);
  }
View Full Code Here

  }

  @Test(expected = ConversionException.class)
  public void testConversionWithNullCharacterInMap() throws ConversionException {
    MongoConnector mdc = mongoConnectorResource.getConnector();
    LocalDocument ld = new LocalDocument();
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("NUL \u0000 here", "");
    ld.putContentField("field", map);
    try {
      mdc.convert(ld);
    } catch (ConversionException e) {
      map.clear();
      map.put("nulvalue", "the \u0000 value");
      ld.putContentField("field", map);
      mdc.convert(ld);
    }
    fail("Was able to put in a map with a null in a field name");
  }
View Full Code Here

public class MongoDocumentTest {

  @Test
  public void testNullTransfer() throws Exception {
    LocalDocument ld = new LocalDocument();
    ld.putContentField("field", "value");
    ld.markSynced();
    ld.removeContentField("field");
   
    MongoDocument md = new MongoDocument(ld.toJson());
   
    assertEquals(1, md.getTouchedContent().size());
    assertNull(md.getContentField("field"));
  }
View Full Code Here

    when(dbc.convert(any(LocalDocument.class))).thenReturn(dbdoc);
   
    when(dbdoc.getID()).thenReturn(null);
   
    RemotePipeline rp = new HttpRemotePipeline("localhost", server.getPort(), "stage");
    LocalDocument ld = new LocalDocument();
   
    boolean result = rp.saveFull(ld);
   
    if(result) {
      fail("Did not get false response");
View Full Code Here

   
    when(dbdoc.getID()).thenReturn(id);
    when(reader.getDocumentById(id)).thenReturn(dbdoc);
   
    RemotePipeline rp = new HttpRemotePipeline("localhost", server.getPort(), "stage");
    LocalDocument ld = new LocalDocument();
   
    boolean result = rp.saveFull(ld);
   
    if(result) {
      fail("Did not get false response on saveFull");
View Full Code Here

 
  ThrowingStage stage = new ThrowingStage();
 
  @Test(expected=RuntimeException.class)
  public void testProcessIsThrowing() throws Exception {
    stage.process(new LocalDocument());
  }
View Full Code Here

public class TikaStageTest {
  @Test
  public void testByDefaultExtractsContentMetadataAndLanguage() throws Exception {
    TikaStage stage = new TikaStage();
    LocalDocument doc = buildDocumentWithResourceFile("/test.pdf");
    stage.process(doc);

    assertThat(doc.getContentFieldAsString("test_pdf_Author"), equalTo("Bertrand Delacrétaz"));
    assertThat(doc.getContentFieldAsString("test_pdf_content"), containsString("Tika is a toolkit for detecting and extracting metadata and structured text content"));
    assertThat(doc.getContentFieldAsString("test_pdf_language"), equalTo("en"));
  }
View Full Code Here

TOP

Related Classes of com.findwise.hydra.local.LocalDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.