Package org.rssowl.core.internal.persist

Examples of org.rssowl.core.internal.persist.Label


  /**
   * Tests {@link MergeUtils#mergeProperties(org.rssowl.core.persist.IEntity, org.rssowl.core.persist.IEntity)}.
   */
  @Test
  public void testMergeProperties() {
    ILabel label0 = new Label(null, "label0");
    String key0 = "key0";
    String value0 = "value0";
    label0.setProperty(key0, value0);
    String key1 = "key1";
    String value1 = "value1";
    label0.setProperty(key1, value1);
    String key2 = "key2";
    String value2 = "value2";
    label0.setProperty(key2, value2);
   
    ILabel label1 = new Label(null, "label1");
    label1.setProperty(key1, value1);
    String newValue2 = "newValue2";
    label1.setProperty(key2, newValue2);
    String key3 = "key3";
    String value3 = "value3";
    label1.setProperty(key3, value3);
   
    ComplexMergeResult<?> mergeResult = MergeUtils.mergeProperties(label0, label1);
    assertEquals(true, mergeResult.getRemovedObjects().contains(value0));
    assertEquals(true, mergeResult.getRemovedObjects().contains(value2));
    assertEquals(true, mergeResult.isStructuralChange());
View Full Code Here


  /**
   * Tests {@link MergeUtils#mergeProperties(org.rssowl.core.persist.IEntity, org.rssowl.core.persist.IEntity)}.
   */
  @Test
  public void testMergeProperties() {
    ILabel label0 = new Label(null, "label0");
    String key0 = "key0";
    String value0 = "value0";
    label0.setProperty(key0, value0);
    String key1 = "key1";
    String value1 = "value1";
    label0.setProperty(key1, value1);
    String key2 = "key2";
    String value2 = "value2";
    label0.setProperty(key2, value2);

    ILabel label1 = new Label(null, "label1");
    label1.setProperty(key1, value1);
    String newValue2 = "newValue2";
    label1.setProperty(key2, newValue2);
    String key3 = "key3";
    String value3 = "value3";
    label1.setProperty(key3, value3);

    ComplexMergeResult<?> mergeResult = MergeUtils.mergeProperties(label0, label1);
    assertEquals(true, mergeResult.getRemovedObjects().contains(value0));
    assertEquals(true, mergeResult.getRemovedObjects().contains(value2));
    assertEquals(true, mergeResult.isStructuralChange());
View Full Code Here

   * Checks: - Addition of label - That ADD event is issued - Updating of label -
   * That UPDATE event is issued - Getting of label
   */
  @Test
  public void testAddUpdateAndGetLabel() {
    final Label initialLabel = (Label) createLabel();
    final Label[] updatedLabel = new Label[1];
    final boolean[] labelAddedCalled = new boolean[] { false };
    final boolean[] labelUpdatedCalled = new boolean[] { false };
    LabelListener labelListener = null;
    try {
      labelListener = new LabelAdapter() {
        @Override
        public void entitiesAdded(Set<LabelEvent> events) {
          for (LabelEvent event : events) {
            labelAddedCalled[0] = true;
            Label dbLabel = (Label) event.getEntity();
            initialLabel.setId(dbLabel.getId());
            assertTrue(initialLabel.isIdentical(dbLabel));
          }
        }

        @Override
        public void entitiesUpdated(Set<LabelEvent> events) {
          LabelEvent event = events.iterator().next();
          labelUpdatedCalled[0] = true;
          Label dbLabel = (Label) event.getEntity();
          assertTrue(updatedLabel[0].isIdentical(dbLabel));
        }
      };
      DynamicDAO.addEntityListener(ILabel.class, labelListener);
      long savedLabelId = DynamicDAO.save(initialLabel).getId().longValue();
      System.gc();
      ILabel dbLabel = DynamicDAO.load(ILabel.class, savedLabelId);
      initialLabel.setId(dbLabel.getId());
      assertTrue(initialLabel.isIdentical(dbLabel));
      dbLabel.setColor("255,255,137");
      updatedLabel[0] = (Label) dbLabel;
      DynamicDAO.save(dbLabel);
      assertTrue(labelAddedCalled[0]);
      assertTrue(labelUpdatedCalled[0]);
      DynamicDAO.delete(updatedLabel[0]);
View Full Code Here

  /**
   * @throws Exception
   */
  @Test
  public void testIsLabelChange() throws Exception {
    ILabel label1 = new Label(null, "Label1");
    ILabel label2 = new Label(null, "Label1");

    IFeed feed = new Feed(new URI("http://www.link.com"));
    INews news1 = new News(null, feed, new Date());
    news1.setLabel(label1);

View Full Code Here

   * Checks: - Addition of label - That ADD event is issued - Updating of label -
   * That UPDATE event is issued - Getting of label
   */
  @Test
  public void testAddUpdateAndGetLabel() {
    final Label initialLabel = (Label) createLabel();
    final Label[] updatedLabel = new Label[1];
    final boolean[] labelAddedCalled = new boolean[] { false };
    final boolean[] labelUpdatedCalled = new boolean[] { false };
    LabelListener labelListener = null;
    try {
      labelListener = new LabelAdapter() {
        @Override
        public void entitiesAdded(Set<LabelEvent> events) {
          for (LabelEvent event : events) {
            labelAddedCalled[0] = true;
            Label dbLabel = (Label) event.getEntity();
            initialLabel.setId(dbLabel.getId());
            assertTrue(initialLabel.isIdentical(dbLabel));
          }
        }

        @Override
        public void entitiesUpdated(Set<LabelEvent> events) {
          LabelEvent event = events.iterator().next();
          labelUpdatedCalled[0] = true;
          Label dbLabel = (Label) event.getEntity();
          assertTrue(updatedLabel[0].isIdentical(dbLabel));
        }
      };
      DynamicDAO.addEntityListener(ILabel.class, labelListener);
      long savedLabelId = DynamicDAO.save(initialLabel).getId().longValue();
      System.gc();
      ILabel dbLabel = DynamicDAO.load(ILabel.class, savedLabelId);
      initialLabel.setId(dbLabel.getId());
      assertTrue(initialLabel.isIdentical(dbLabel));
      dbLabel.setColor("255,255,137");
      updatedLabel[0] = (Label) dbLabel;
      DynamicDAO.save(dbLabel);
      assertTrue(labelAddedCalled[0]);
      assertTrue(labelUpdatedCalled[0]);
      DynamicDAO.delete(updatedLabel[0]);
View Full Code Here

  /**
   * @throws Exception
   */
  @Test
  public void testIsLabelChangeSingle() throws Exception {
    ILabel label1 = new Label(null, "Label1");
    ILabel label2 = new Label(null, "Label2");

    IFeed feed = new Feed(new URI("http://www.link.com"));
    INews news1 = new News(null, feed, new Date());
    news1.addLabel(label1);

View Full Code Here

  /**
   * @throws Exception
   */
  @Test
  public void testIsLabelChangeMulti() throws Exception {
    ILabel label1 = new Label(null, "Label1");
    ILabel label2 = new Label(null, "Label2");
    ILabel label3 = new Label(null, "Label3");

    IFeed feed = new Feed(new URI("http://www.link.com"));
    INews news1 = new News(null, feed, new Date());
    news1.addLabel(label1);
    news1.addLabel(label3);
View Full Code Here

   * {@link MergeUtils#mergeProperties(org.rssowl.core.persist.IEntity, org.rssowl.core.persist.IEntity)}
   * .
   */
  @Test
  public void testMergeProperties() {
    ILabel label0 = new Label(null, "label0");
    String key0 = "key0";
    String value0 = "value0";
    label0.setProperty(key0, value0);
    String key1 = "key1";
    String value1 = "value1";
    label0.setProperty(key1, value1);
    String key2 = "key2";
    String value2 = "value2";
    label0.setProperty(key2, value2);
    String key3 = SyncUtils.GOOGLE_MARKED_READ;
    String value3 = "value3";
    label0.setProperty(key3, value3);

    ILabel label1 = new Label(null, "label1");
    label1.setProperty(key1, value1);
    String newValue2 = "newValue2";
    label1.setProperty(key2, newValue2);
    key3 = "key3";
    value3 = "value3";
    label1.setProperty(key3, value3);

    ComplexMergeResult<?> mergeResult = MergeUtils.mergeProperties(label0, label1);
    assertEquals(true, mergeResult.getRemovedObjects().contains(value0));
    assertEquals(true, mergeResult.getRemovedObjects().contains(value2));
    assertEquals(true, mergeResult.isStructuralChange());

    assertEquals(4, label0.getProperties().size());
    assertEquals(3, label1.getProperties().size());
    assertEquals(value1, label0.getProperties().get(key1));
    assertEquals(newValue2, label0.getProperties().get(key2));
    assertEquals(value3, label0.getProperties().get(key3));
  }
View Full Code Here

   * {@link MergeUtils#mergeProperties(org.rssowl.core.persist.IEntity, org.rssowl.core.persist.IEntity)}
   * .
   */
  @Test
  public void testMergeExcludedProperties() {
    ILabel label0 = new Label(null, "label0");
    String key0 = SyncUtils.GOOGLE_MARKED_READ;
    String value0 = "value0";
    label0.setProperty(key0, value0);
    String key1 = SyncUtils.GOOGLE_MARKED_UNREAD;
    String value1 = "value1";
    label0.setProperty(key1, value1);
    String key2 = SyncUtils.GOOGLE_LABELS;
    String value2 = "value2";
    label0.setProperty(key2, value2);

    ILabel label1 = new Label(null, "label1");

    ComplexMergeResult<?> mergeResult = MergeUtils.mergeProperties(label0, label1);
    assertEquals(true, mergeResult.getRemovedObjects().isEmpty());
    assertEquals(false, mergeResult.isStructuralChange());

    assertEquals(3, label0.getProperties().size());
    assertEquals(0, label1.getProperties().size());
  }
View Full Code Here

  /**
   * @throws Exception
   */
  @Test
  public void testIsLabelChangeSingle() throws Exception {
    ILabel label1 = new Label(null, "Label1");
    ILabel label2 = new Label(null, "Label2");

    IFeed feed = new Feed(new URI("http://www.link.com"));
    INews news1 = new News(null, feed, new Date());
    news1.addLabel(label1);

View Full Code Here

TOP

Related Classes of org.rssowl.core.internal.persist.Label

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.