@Test public void getNextTest() { // client cannot be invalid try { SequenceCore.getNext("isha", "seq1", 5); assertTrue(false); } catch (APIException ex) { assertEquals(Status.ERROR_RESOURCE_NOT_FOUND, ex.statusCode); } Client.create("Isha"); // error if incorrect input try { SequenceCore.getNext("isha", "seq1", 0); assertTrue(false); } catch (APIException ex) { assertEquals(Status.ERROR_RESOURCE_INCORRECT, ex.statusCode); } // error if incorrect input try { SequenceCore.getNext("isha", "seq1", -1); assertTrue(false); } catch (APIException ex) { assertEquals(Status.ERROR_RESOURCE_INCORRECT, ex.statusCode); } List<Long> ids = SequenceCore.getNext("isha", "sEQ1", 5); assertEquals(5, ids.size()); assertEquals(1, ids.get(0).longValue()); assertEquals(2, ids.get(1).longValue()); assertEquals(3, ids.get(2).longValue()); assertEquals(4, ids.get(3).longValue()); assertEquals(5, ids.get(4).longValue()); // ensure it works for 1 ids = SequenceCore.getNext("isha", "seq1", 1); assertEquals(1, ids.size()); assertEquals(6, ids.get(0).longValue()); assertEquals(7, SequenceCore.getNext("isha", "seq1", 1).iterator().next().longValue()); // for some other sequence types ids = SequenceCore.getNext("isha", "seq2", 2); assertEquals(2, ids.size()); assertEquals(1, ids.get(0).longValue()); assertEquals(2, ids.get(1).longValue()); }
@Before public void setUp() { datastoreHelper.setUp(); ObjectifyFilter.complete(); Client.create(client); sgp = Group.create(client, "Singapore", User.SUPER_USER); assertEquals(1, sgp.groupId); kl = Group.create(client, "KL", User.SUPER_USER); assertEquals(2, kl.groupId); validUser = User.create(client, "*****@*****.**", sgp.groupId, User.SUPER_USER); userWithSendMailPermissionForSgp = User.create(client, "*****@*****.**", sgp.groupId, User.SUPER_USER); User.addGroupLevelPrivilege( client, sgp.groupId, userWithSendMailPermissionForSgp.email, GroupLevelPrivilege.SEND_EMAIL, User.SUPER_USER); sgpTeachers = List.createRestricted(client, sgp.groupId, "Sgp Teachers", null, User.SUPER_USER); ContactProp c = new ContactProp(); c.email = "*****@*****.**"; c.asOfyyyymmdd = 20141026; c.firstName = "Sathya"; sathya = Member.create(client, sgp.groupId, c, false, User.SUPER_USER); c.firstName = "Sharmila"; c.mobilePhone = "+6593849384"; c.email = null; sharmila = Member.create(client, sgp.groupId, c, false, User.SUPER_USER); assertEquals("Sharmila", sharmila.contact.firstName); c.email = "*****@*****.**"; murugavel = Member.create(client, sgp.groupId, c, false, User.SUPER_USER); assertEquals("*****@*****.**", murugavel.contact.email); // add sathya and sharmila to sgpTeachers Member.addOrDeleteList(client, sathya.memberId, sgpTeachers.listId, true, User.SUPER_USER); Member.addOrDeleteList(client, sharmila.memberId, sgpTeachers.listId, true, User.SUPER_USER); Member.subscribeGroup(client, sathya.memberId, sgp.groupId, User.SUPER_USER); Member.subscribeGroup(client, sharmila.memberId, sgp.groupId, User.SUPER_USER); ObjectifyFilter.complete(); }