public void testOrgDefautRegistrationToken() throws Exception { User user = UserTestUtils.findNewUser("testUser", "testOrg", true); Org orig = user.getOrg(); orig.setName("org created by OrgFactory test: " + TestUtils.randomString()); // build the channels set Channel channel1 = ChannelFactoryTest.createTestChannel(orig); flushAndEvict(channel1); orig.addOwnedChannel(channel1); orig = OrgFactory.save(orig); assertTrue(orig.getId().longValue() > 0); assertNull(orig.getToken()); ActivationKey key = ActivationKeyTest.createTestActivationKey(user); // Token is hidden behind activation key so we have to look it up // manually: Token token = TokenFactory.lookupById(key.getId()); orig.setToken(token); orig = OrgFactory.save(orig); Long origId = orig.getId(); flushAndEvict(orig); Org lookup = OrgFactory.lookupById(origId); assertEquals(token.getId(), lookup.getToken().getId()); lookup.setToken(null); flushAndEvict(lookup); lookup = OrgFactory.lookupById(origId); assertNull(lookup.getToken()); }
private Org createTestOrg() throws Exception { Org org1 = OrgFactory.createOrg(); org1.setName("org created by OrgFactory test: " + TestUtils.randomString()); org1 = OrgFactory.save(org1); // build the channels set Channel channel1 = ChannelFactoryTest.createTestChannel(org1); flushAndEvict(channel1); org1.addOwnedChannel(channel1); assertTrue(org1.getId().longValue() > 0); return org1; }