/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
- /*
- * Copyright (c) 2011. Tonic Solutions, LLC. All Rights Reservered. This Code is distributed under GPL V3 without any warrenty.
- */
- import com.nimbits.client.model.category.Category;
- import com.nimbits.client.model.category.CategoryName;
- import com.nimbits.client.model.common.CommonFactoryLocator;
- import org.junit.Assert;
- import org.junit.Test;
- import java.util.List;
- import java.util.UUID;
- /**
- * Created by bsautner
- * User: benjamin
- * Date: 3/30/11
- * Time: 9:28 AM
- *
- */
- public class CategoryServiceTest {
- @Test
- public void TestCategoryCrud() throws Exception {
- CategoryName n = CommonFactoryLocator.getInstance().createCategoryName(UUID.randomUUID().toString());
- Category c = Common.client().addCategory(n);
- Assert.assertNotNull(c);
- Assert.assertTrue(c.getId() > 0);
- Thread.sleep(1000);
- List<Category> l = Common.client().getCategories(true,true);
- Assert.assertNotNull(l);
- Thread.sleep(1000);
- boolean found = false;
- for (Category cx : l) {
- // System.out.println(cx.getValue());
- if (cx.getName().equals(n)) {
- found = true;
- break;
- }
- }
- Assert.assertTrue(found);
- Thread.sleep(1000);
- Category cx2 = Common.client().getCategory(n, false,false);
- Assert.assertNotNull(cx2);
- Assert.assertEquals(cx2.getId(), c.getId());
- Common.client().deleteCategory(n);
- Thread.sleep(1000);
- l = Common.client().getCategories(true, true);
- found = false;
- for (Category cx : l) {
- if (cx.getName().equals(n)) {
- found = true;
- break;
- }
- }
- Assert.assertTrue(!found);
- }
- }