use of org.olat.modules.gotomeeting.GoToOrganizer in project OpenOLAT by OpenOLAT.
the class GoToOrganizerDAOTest method createOrganizer_withOwner.
@Test
public void createOrganizer_withOwner() {
Identity org = JunitTestHelper.createAndPersistIdentityAsRndUser("organizer-1");
String username = UUID.randomUUID().toString();
String accessToken = UUID.randomUUID().toString();
String organizerKey = UUID.randomUUID().toString();
GoToOrganizer organizer = organizerDao.createOrganizer(null, username, accessToken, organizerKey, "Albrecht", "Durer", "albert@openolat.com", "account-key", 1200l, org);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(organizer);
GoToOrganizer reloadedOrganizer = organizerDao.loadOrganizerByKey(organizer.getKey());
Assert.assertNotNull(reloadedOrganizer);
Assert.assertEquals(organizer.getKey(), reloadedOrganizer.getKey());
Assert.assertNotNull(organizer.getCreationDate());
Assert.assertNotNull(organizer.getLastModified());
Assert.assertEquals(username, reloadedOrganizer.getUsername());
Assert.assertEquals(accessToken, reloadedOrganizer.getAccessToken());
Assert.assertEquals(organizerKey, reloadedOrganizer.getOrganizerKey());
Assert.assertEquals(org, reloadedOrganizer.getOwner());
}
use of org.olat.modules.gotomeeting.GoToOrganizer in project OpenOLAT by OpenOLAT.
the class GoToOrganizerDAOTest method organizerExists.
@Test
public void organizerExists() {
String username = UUID.randomUUID().toString();
String accessToken = UUID.randomUUID().toString();
String organizerKey = UUID.randomUUID().toString();
GoToOrganizer organizer = organizerDao.createOrganizer(null, username, accessToken, organizerKey, "Johann", "Amerbach", null, null, 10l, null);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(organizer);
boolean exists = organizerDao.organizerExists(username);
Assert.assertTrue(exists);
boolean notExists = organizerDao.organizerExists(accessToken);
Assert.assertFalse(notExists);
}
use of org.olat.modules.gotomeeting.GoToOrganizer in project OpenOLAT by OpenOLAT.
the class GoToOrganizerDAOTest method getOrganizers.
@Test
public void getOrganizers() {
String username = UUID.randomUUID().toString();
String accessToken = UUID.randomUUID().toString();
String organizerKey = UUID.randomUUID().toString();
GoToOrganizer organizer = organizerDao.createOrganizer(null, username, accessToken, organizerKey, "Martin", "Schongauer", null, null, 10l, null);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(organizer);
// load by user name
List<GoToOrganizer> organizers = organizerDao.getOrganizers();
Assert.assertNotNull(organizers);
Assert.assertFalse(organizers.isEmpty());
Assert.assertTrue(organizers.contains(organizer));
}
use of org.olat.modules.gotomeeting.GoToOrganizer in project OpenOLAT by OpenOLAT.
the class GoToOrganizerDAO method deleteOrganizer.
public void deleteOrganizer(GoToOrganizer organizer) {
GoToOrganizer organizerRef = dbInstance.getCurrentEntityManager().getReference(GoToOrganizerImpl.class, organizer.getKey());
dbInstance.getCurrentEntityManager().remove(organizerRef);
}
use of org.olat.modules.gotomeeting.GoToOrganizer in project OpenOLAT by OpenOLAT.
the class GoToMeetingManagerImpl method getTraining.
private GoToTrainingG2T getTraining(GoToMeeting meeting, GoToError error) {
try (CloseableHttpClient httpClient = HttpClientBuilder.create().build()) {
GoToOrganizer organizer = meeting.getOrganizer();
String url = gotoTrainingUrl + "/organizers/" + organizer.getOrganizerKey() + "/trainings/" + meeting.getMeetingKey();
HttpGet get = new HttpGet(url);
get.addHeader("Accept", "application/json");
get.addHeader("Authorization", "OAuth oauth_token=" + organizer.getAccessToken());
get.addHeader("Content-type", "application/json");
HttpResponse response = httpClient.execute(get);
int status = response.getStatusLine().getStatusCode();
if (status == 200) {
// deleted
String content = EntityUtils.toString(response.getEntity());
GoToTrainingG2T trainingVo = GoToJsonUtil.parseTraining(content);
return trainingVo;
} else {
logGoToError("getTraining", response, error);
return null;
}
} catch (Exception e) {
log.error("", e);
return null;
}
}
Aggregations