Package com.directededge

Examples of com.directededge.Item


    }

    @Test(expected = IllegalArgumentException.class)
    public void weightedLinksLowerLimit()
    {
        Item customer = new Item(database, "customer0");
        Item product = new Item(database, "product0");
        customer.linkTo(product, -1);
    }
View Full Code Here


    }

    @Test
    public void typedLinks()
    {
        Item customer = new Item(database, "customer0");
        Item product = new Item(database, "product0");
        customer.linkTo(product, "purchase");
        customer.save();

        customer = new Item(database, "customer0");
        assertTrue(customer.getLinks("purchase").containsKey("product0"));

        customer.linkTo(product, 5, "wishlist");
        customer.save();

        customer = new Item(database, "customer0");
        customer.getLinks();
        assertEquals(5, customer.getLinks("wishlist").get("product0").intValue());
    }
View Full Code Here

    }

    @Test
    public void tags()
    {
        Item customer = new Item(database, "customer0");
        assertTrue(customer.getTags().contains("customer"));
        customer.addTag("test");
        assertTrue(customer.getTags().contains("test"));
        customer.save();
        customer = new Item(database, "customer0");
        assertTrue(customer.getTags().contains("test"));
        customer.removeTag("test");
        assertFalse(customer.getTags().contains("test"));
        customer.save();
        customer = new Item(database, "customer0");
        assertFalse(customer.getTags().contains("test"));
    }
View Full Code Here

    }

    @Test
    public void properties()
    {
        Item customer = new Item(database, "customer0");
        customer.setProperty("test", "first");
        assertEquals("first", customer.getProperty("test"));
        customer.setProperty("test", "second");
        assertEquals("second", customer.getProperty("test"));
        customer.save();
        customer = new Item(database, "customer0");
        assertEquals(1, customer.getProperties().size());
        assertEquals("second", customer.getProperty("test"));
        customer.setProperty("test", "third");
        customer.save();
        assertEquals("third", customer.getProperty("test"));
        customer = new Item(database, "customer0");
        assertEquals("third", customer.getProperty("test"));
        customer.clearProperty("test");
        assertEquals(0, customer.getProperties().size());
        customer.save();
        customer = new Item(database, "customer0");
        assertEquals(0, customer.getProperties().size());
    }
View Full Code Here

    public void recommended()
    {
        HashSet<String> tags = new HashSet<String>();
        tags.add("product");

        Item customer = new Item(database, "customer0");
        assertEquals(20, customer.getRecommended().size());
        assertEquals(20, customer.getRecommended(tags).size());
        assertEquals(5, customer.getRecommended(tags, 5).size());
    }
View Full Code Here

    public void related()
    {
        HashSet<String> tags = new HashSet<String>();
        tags.add("product");

        Item product = new Item(database, "product0");
        assertEquals(20, product.getRelated().size());
        assertEquals(20, product.getRelated(tags).size());
        assertEquals(5, product.getRelated(tags, 5).size());

        HashMap<String, Object> options = new HashMap<String, Object>();
        options.put("popularity", 5);

        List<String> popular = product.getRelated(tags, options);

        options.put("popularity", 1);

        List<String> unpopular = product.getRelated(tags, options);

        assertFalse(popular.equals(unpopular));
    }
View Full Code Here

        importTest(database);
    }

    private void importTest(Database database)
    {
        Item customer0 = new Item(database, "customer0");
        assertEquals(customer0.getLinks("").size(), 10);

        Item product49 = new Item(database, "product49");
        assertEquals(product49.getLinks("").size(), 0);
        assertTrue(product49.getTags().contains("product"));
        assertFalse(product49.getTags().contains("user"));
    }
View Full Code Here

    }

    private void export(Exporter exporter) throws ParserConfigurationException,
            SAXException, IOException
    {
        Item first = new Item(exporter.getDatabase(), "first");
        Item second = new Item(exporter.getDatabase(), "second");
        first.linkTo(second);
        first.addTag("tag1");
        second.addTag("tag2");
        first.setProperty("testkey", "testvalue");
        exporter.export(first);
        exporter.export(second);
        exporter.finish();
View Full Code Here

TOP

Related Classes of com.directededge.Item

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.