PageRenderTime 28ms CodeModel.GetById 18ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/v3.2/nimbits-sdk/test/CategoryServiceTest.java

http://nimbits-server.googlecode.com/
Java | 70 lines | 43 code | 16 blank | 11 comment | 4 complexity | fec2f2fe102da2b8eac76df7ef6d0ddb MD5 | raw file
 1/*
 2 * Copyright (c) 2011. Tonic Solutions, LLC. All Rights Reservered. This Code is distributed under GPL V3 without any warrenty.
 3 */
 4
 5import com.nimbits.client.model.category.Category;
 6import com.nimbits.client.model.category.CategoryName;
 7import com.nimbits.client.model.common.CommonFactoryLocator;
 8import org.junit.Assert;
 9import org.junit.Test;
10
11import java.util.List;
12import java.util.UUID;
13
14/**
15 * Created by bsautner
16 * User: benjamin
17 * Date: 3/30/11
18 * Time: 9:28 AM
19 *
20 */
21public class CategoryServiceTest {
22
23    @Test
24    public void TestCategoryCrud() throws Exception {
25
26        CategoryName n =   CommonFactoryLocator.getInstance().createCategoryName(UUID.randomUUID().toString());
27        Category c = Common.client().addCategory(n);
28        Assert.assertNotNull(c);
29        Assert.assertTrue(c.getId() > 0);
30        Thread.sleep(1000);
31        List<Category> l = Common.client().getCategories(true,true);
32        Assert.assertNotNull(l);
33        Thread.sleep(1000);
34        boolean found = false;
35        for (Category cx : l) {
36            //  System.out.println(cx.getValue());
37            if (cx.getName().equals(n)) {
38                found = true;
39                break;
40            }
41        }
42        Assert.assertTrue(found);
43
44        Thread.sleep(1000);
45        Category cx2 = Common.client().getCategory(n, false,false);
46
47        Assert.assertNotNull(cx2);
48
49        Assert.assertEquals(cx2.getId(), c.getId());
50
51
52        Common.client().deleteCategory(n);
53        Thread.sleep(1000);
54        l = Common.client().getCategories(true, true);
55        found = false;
56        for (Category cx : l) {
57
58            if (cx.getName().equals(n)) {
59                found = true;
60                break;
61            }
62        }
63
64
65        Assert.assertTrue(!found);
66
67    }
68
69
70}