PageRenderTime 92ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/src/test/java/halleck/webserver/CourseLoaderTest.java

https://gitlab.com/soylentcode/halleck
Java | 43 lines | 34 code | 9 blank | 0 comment | 0 complexity | a816e0e7e890270cfef620b4ee5a93b1 MD5 | raw file
  1. package halleck.webserver;
  2. import com.google.common.collect.Iterables;
  3. import com.google.gson.Gson;
  4. import halleck.lms.Course;
  5. import org.junit.Test;
  6. import java.util.ArrayList;
  7. import java.util.Collection;
  8. import static com.google.common.collect.Lists.newArrayList;
  9. import static com.mongodb.util.MyAsserts.assertEquals;
  10. import static halleck.lms.Utils.toInteger;
  11. public class CourseLoaderTest {
  12. @Test
  13. public void testGSonStuff() throws Exception {
  14. CourseLoader l = new CourseLoader(null, null, null);
  15. Course source = new Course("42", "Underwater Basketweaving");
  16. source.setDecription("a long long description");
  17. source.setUrl("http://www.google.com");
  18. source.setMaxCapacity(2);
  19. source.setContent("fishy content");
  20. source.setOwner("Thufir");
  21. ArrayList<Course> sourceList = newArrayList(source);
  22. String content = new Gson().toJson(sourceList);
  23. Collection<Course> courses = l.createCourseArray(content);
  24. Course c = courses.stream().findAny().get();
  25. assertEquals(1, courses.size());
  26. assertEquals("42", c.getId());
  27. assertEquals("Underwater Basketweaving", c.getName());
  28. assertEquals("a long long description", c.getDescription());
  29. assertEquals("http://www.google.com", c.getUrl());
  30. assertEquals((Integer)2, c.getMaxEnrollment());
  31. assertEquals("fishy content", c.getContent());
  32. assertEquals("Thufir", c.getOwner());
  33. }
  34. }