Package com.findwise.hydra.local

Examples of com.findwise.hydra.local.LocalDocument


*/
public class RemoveFieldsTest {

    @Test
    public void testProcess() throws Exception {
        LocalDocument doc = new LocalDocument();
        doc.putContentField("title", "Supertitle");
        doc.putContentField("type", "Supertype");
        doc.putContentField("some_numeric_3", "");
       
        LinkedList<String> removeFields = new LinkedList<String>();
        removeFields.add("title");
        removeFields.add("otherObject");
        removeFields.add("field_not_existing");
        removeFields.add(".*[0-9]+");
       
        assertNotNull("Should not have been removed yet", doc.getContentField("title"));
       
        RemoveFieldsStage stage = new RemoveFieldsStage();
        stage.setRemoveFields(removeFields);
        stage.init();
        stage.process(doc);
       
        assertTrue("Should not have been removed", doc.hasContentField("type"));
       
        assertFalse("Should have been removed", doc.hasContentField("title"));
        assertFalse("Should have been removed", doc.hasContentField("some_numeric_3"));
    }
View Full Code Here


  @Test
  public void testProcess_calls_fetch()
      throws Exception, IOException,
      URISyntaxException {
    doc = new LocalDocument();
    String testIdentifier = createTestIdentifier("someidentifier");
    doc.putContentField("url", testIdentifier);
    stage.process(doc);
    verify(fetcher).fetch(testIdentifier, stage.getAcceptedContentHeader(), stage, stage);
  }
View Full Code Here

  @Test
  public void testProcess_calls_client_with_request_for_url_list()
      throws Exception, IOException,
      URISyntaxException {
    doc = new LocalDocument();
    List<String> urls = Arrays.asList(
        createTestIdentifier("someidentifier1"),
        createTestIdentifier("someidentifier2"),
        createTestIdentifier("someidentifier3"));
    doc.putContentField("url", urls);
View Full Code Here

  @Test
  public void testProcess_adds_ignored_identifier_to_mapped_field() throws
      Exception,
      IOException,
      URISyntaxException {
    doc = new LocalDocument();
    List<String> urls = Arrays.asList(
        createTestIdentifier("someidentifier1"),
        createTestIdentifier("someidentifier2"));
    doc.putContentField("url", urls);
    doc.putContentField("some_output_field", "not an identifier");
View Full Code Here

  private LocalDocument doc;

  @Before
  public void setUp() {
    stage = new MergeListsStage();
    doc = new LocalDocument();
 
View Full Code Here

  private Map<String, String> config1;

  @Before
  public void setUp() {
    regexStage = new RegexStage();
    doc = new LocalDocument();
    configs = new ArrayList<Map<String, String>>();
    config1 = new HashMap<String, String>();
    config1.put("inField", "rawcontent");
    config1.put("outField", "out");
  }
View Full Code Here

    assertEquals(
        "<html><head></head><body><h1 class=\"BIG\">h1 #1</h1><h1>h1 #2</h1><h2>h2 #1</h2><h2>h2 #2</h2></body></html>",
        doc.getContentField("out").toString());

    // should not match
    LocalDocument doc2 = new LocalDocument();
    doc2.putContentField(
        "rawcontent",
        "<html><head></head><body><h1 class=\"BIG\">h1 #1</h1><h1>h1 #2</h1><h2>h2 #1</h2><h2>h2 #2</h2></body></html>");
    regexStage.process(doc2);
    assertTrue(!doc2.hasContentField("out"));
  }
View Full Code Here

        String epochTest = "1377174053";
        String expected = "2013-08-22T12:20:53Z";
        setupStage();

        LocalDocument ld = new LocalDocument();
        ld.putContentField("date", epochTest);

        subject.process(ld);

        assertEquals(expected, ld.getContentField("date"));
    }
View Full Code Here

        String epochTest = "1377174053";
        String expected = "2013-08-22T14:20:53Z";
        subject.setEpochTimeZone("+0200");
        setupStage();

        LocalDocument ld = new LocalDocument();
        ld.putContentField("date", epochTest);

        subject.process(ld);

        assertEquals(expected, ld.getContentField("date"));
    }
View Full Code Here

            Exception, RequiredArgumentMissingException {
        String iso8601 = "2012-06-29T10:42:53+02:00";
        String expected = "2012-06-29T08:42:53Z";
        setupStage();

        LocalDocument ld = new LocalDocument();
        ld.putContentField("date", iso8601);

        subject.process(ld);

        assertEquals(expected, ld.getContentField("date"));
    }
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.