/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. import com.nimbits.client.model.category.Category;
  5. import com.nimbits.client.model.category.CategoryName;
  6. import com.nimbits.client.model.common.CommonFactoryLocator;
  7. import org.junit.Assert;
  8. import org.junit.Test;
  9. import java.util.List;
  10. import java.util.UUID;
  11. /**
  12. * Created by bsautner
  13. * User: benjamin
  14. * Date: 3/30/11
  15. * Time: 9:28 AM
  16. *
  17. */
  18. public class CategoryServiceTest {
  19. @Test
  20. public void TestCategoryCrud() throws Exception {
  21. CategoryName n = CommonFactoryLocator.getInstance().createCategoryName(UUID.randomUUID().toString());
  22. Category c = Common.client().addCategory(n);
  23. Assert.assertNotNull(c);
  24. Assert.assertTrue(c.getId() > 0);
  25. Thread.sleep(1000);
  26. List<Category> l = Common.client().getCategories(true,true);
  27. Assert.assertNotNull(l);
  28. Thread.sleep(1000);
  29. boolean found = false;
  30. for (Category cx : l) {
  31. // System.out.println(cx.getValue());
  32. if (cx.getName().equals(n)) {
  33. found = true;
  34. break;
  35. }
  36. }
  37. Assert.assertTrue(found);
  38. Thread.sleep(1000);
  39. Category cx2 = Common.client().getCategory(n, false,false);
  40. Assert.assertNotNull(cx2);
  41. Assert.assertEquals(cx2.getId(), c.getId());
  42. Common.client().deleteCategory(n);
  43. Thread.sleep(1000);
  44. l = Common.client().getCategories(true, true);
  45. found = false;
  46. for (Category cx : l) {
  47. if (cx.getName().equals(n)) {
  48. found = true;
  49. break;
  50. }
  51. }
  52. Assert.assertTrue(!found);
  53. }
  54. }