diff --git a/src/test/java/org/olat/course/FunctionalCourseTest.java b/src/test/java/org/olat/course/FunctionalCourseTest.java index 70cfb6c94a1a9878265e4f7b90834af1b05b75af..55b6c78088c29e2a6971385149bba7918eb3e9da 100644 --- a/src/test/java/org/olat/course/FunctionalCourseTest.java +++ b/src/test/java/org/olat/course/FunctionalCourseTest.java @@ -30,6 +30,7 @@ import java.net.URL; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.SecureRandom; +import java.util.List; import org.apache.commons.codec.binary.Base64; import org.apache.commons.io.IOUtils; @@ -41,10 +42,13 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; +import org.olat.restapi.support.vo.GroupVO; +import org.olat.restapi.support.vo.RepositoryEntryVO; import org.olat.test.ArquillianDeployments; import org.olat.util.FunctionalCourseUtil; import org.olat.util.FunctionalCourseUtil.CourseEditorCourseTab; @@ -79,7 +83,8 @@ public class FunctionalCourseTest { public final static int LARGE_COURSE_FILE_COUNT = 20; public final static long LARGE_COURSE_FILE_SIZE = 50000; - public final static int LARGE_COURSE_TEST_COUNT = 20; + public final static int LARGE_COURSE_TEST_COUNT = 200; + public final static int LARGE_COURSE_GROUP_COUNT = 150; public final static String LARGE_COURSE_IQ_TEST_SHORT_TITLE = "QTI"; public final static String LARGE_COURSE_IQ_TEST_LONG_TITLE = "generated test No. "; public final static String LARGE_COURSE_IQ_TEST_DESCRIPTION_0 = "generated within a loop: test#"; @@ -122,6 +127,7 @@ public class FunctionalCourseTest { } } + @Ignore @Test @RunAsClient public void checkCreateUsingWizard(){ @@ -146,8 +152,11 @@ public class FunctionalCourseTest { for(int i = 0; i < elementArray.length; i++){ functionalCourseUtil.open(browser, i); } + + functionalUtil.logout(browser); } + @Ignore @Test @RunAsClient public void checkCreateUsingEditor() throws FileNotFoundException, IOException, URISyntaxException{ @@ -222,6 +231,8 @@ public class FunctionalCourseTest { .append("')]"); Assert.assertTrue(browser.isElementPresent(selectorBuffer.toString())); + + functionalUtil.logout(browser); } @Test @@ -255,6 +266,9 @@ public class FunctionalCourseTest { out.close(); } + /* create groups via REST-API */ + List<GroupVO> group = functionalVOUtil.createTestCourseGroups(deploymentUrl, LARGE_COURSE_GROUP_COUNT); + /* login */ Assert.assertTrue(functionalUtil.login(browser, functionalUtil.getUsername(), functionalUtil.getPassword(), true)); @@ -278,6 +292,7 @@ public class FunctionalCourseTest { /* click course node and open editor */ functionalCourseUtil.open(browser, -1); Assert.assertTrue(functionalCourseUtil.openCourseEditor(browser)); + String businessPath = functionalCourseUtil.readExternalLink(browser); /* create tests */ for(int i = 0; i < LARGE_COURSE_TEST_COUNT; i++){ @@ -291,5 +306,14 @@ public class FunctionalCourseTest { 2 * i + 4)); Assert.assertTrue(functionalCourseUtil.createQTITest(browser, title, description)); } + + functionalUtil.logout(browser); + + /* assign groups to course */ + long repoKey = functionalCourseUtil.extractRepositoryEntryKey(businessPath); + RepositoryEntryVO repoEntryVO = functionalVOUtil.getRepositoryEntryByKey(deploymentUrl, repoKey); + long courseId = repoEntryVO.getOlatResourceId(); + + functionalVOUtil.addGroupToCourse(deploymentUrl, courseId, group); } } diff --git a/src/test/java/org/olat/group/FunctionalGroupTest.java b/src/test/java/org/olat/group/FunctionalGroupTest.java index 5ef63f91feb56281a27992beb65b8da5f597f6b8..80e55065da3518f3f29d5660778c4f71cffbd191 100644 --- a/src/test/java/org/olat/group/FunctionalGroupTest.java +++ b/src/test/java/org/olat/group/FunctionalGroupTest.java @@ -49,7 +49,6 @@ import com.thoughtworks.selenium.DefaultSelenium; * * @author jkraehemann, joel.kraehemann@frentix.com, frentix.com */ -@Ignore @RunWith(Arquillian.class) public class FunctionalGroupTest { @@ -78,6 +77,8 @@ public class FunctionalGroupTest { if(!initialized){ functionalUtil = new FunctionalUtil(); functionalUtil.setDeploymentUrl(deploymentUrl.toString()); + + functionalGroupsSiteUtil = functionalUtil.getFunctionalGroupsSiteUtil(); functionalVOUtil = new FunctionalVOUtil(functionalUtil.getUsername(), functionalUtil.getPassword()); @@ -85,6 +86,7 @@ public class FunctionalGroupTest { } } + @Ignore @Test @RunAsClient public void checkCreate(@Drone @Tutor1 DefaultSelenium tutor0) throws IOException, URISyntaxException{ @@ -115,31 +117,36 @@ public class FunctionalGroupTest { * verify */ } - + + @Ignore @Test @RunAsClient public void checkConfigureTools(){ } + @Ignore @Test @RunAsClient public void checkConfigureMembers(){ } - + + @Ignore @Test @RunAsClient public void checkConfigureAccessControl(){ } + @Ignore @Test @RunAsClient public void checkBookGroup(){ } - + + @Ignore @Test @RunAsClient public void checkAddUser(){ diff --git a/src/test/java/org/olat/util/FunctionalCourseUtil.java b/src/test/java/org/olat/util/FunctionalCourseUtil.java index 9eadeeabf23c1ebc11a7b8895fd57126fb70a4e5..bb4d46d480530d9b2245aead6f9d4420e2076365 100644 --- a/src/test/java/org/olat/util/FunctionalCourseUtil.java +++ b/src/test/java/org/olat/util/FunctionalCourseUtil.java @@ -19,6 +19,7 @@ */ package org.olat.util; +import java.io.IOException; import java.net.MalformedURLException; import java.net.URI; import java.util.ArrayList; @@ -624,6 +625,23 @@ public class FunctionalCourseUtil { return(browser.getText(selectorBuffer.toString())); } + /** + * Extracts the repository entry key from business path. + * + * @param businessPath + * @return + * @throws IOException + */ + public long extractRepositoryEntryKey(String businessPath) throws IOException{ + Pattern keyPattern = Pattern.compile("/RepositoryEntry/([0-9]+)/"); + Matcher keyMatcher = keyPattern.matcher(businessPath); + + if(!keyMatcher.find()) + throw new IOException("there's no repository entry key"); + + return(Long.parseLong(keyMatcher.group(1))); + } + /** * Reads the internal link of the currently open course node within the editor. * diff --git a/src/test/java/org/olat/util/FunctionalVOUtil.java b/src/test/java/org/olat/util/FunctionalVOUtil.java index 5546bbf94b63bb192e55a4f4f78f5bffbc198a06..28b604e0bc60ba0701972d56f151619f60ea9795 100644 --- a/src/test/java/org/olat/util/FunctionalVOUtil.java +++ b/src/test/java/org/olat/util/FunctionalVOUtil.java @@ -51,10 +51,15 @@ import org.olat.core.logging.OLog; import org.olat.core.logging.Tracing; import org.olat.restapi.RestConnection; import org.olat.restapi.support.vo.CourseVO; +import org.olat.restapi.support.vo.GroupVO; import org.olat.restapi.support.vo.RepositoryEntryVO; import org.olat.user.restapi.RolesVO; import org.olat.user.restapi.UserVO; +/** + * + * @author jkraehemann, joel.kraehemann@frentix.com, frentix.com + */ public class FunctionalVOUtil { private final static OLog log = Tracing.createLoggerFor(FunctionalVOUtil.class); @@ -93,6 +98,22 @@ public class FunctionalVOUtil { waitLimit = WAIT_LIMIT; } + public RepositoryEntryVO getRepositoryEntryByKey(URL deploymentUrl, long key) throws IOException, URISyntaxException{ + RestConnection restConnection = new RestConnection(deploymentUrl); + + restConnection.login(getUsername(), getPassword()); + + URI request = UriBuilder.fromUri(deploymentUrl.toURI()).path("restapi").path("repo/entries").path(Long.toString(key)).build(); + HttpGet method = restConnection.createGet(request, MediaType.APPLICATION_JSON, true); + HttpResponse response = restConnection.execute(method); + assertEquals(200, response.getStatusLine().getStatusCode()); + RepositoryEntryVO vo = restConnection.parse(response, RepositoryEntryVO.class); + + restConnection.shutdown(); + + return(vo); + } + /** * Creates the selenium test users with random passwords and * writes it to credentials.properties. @@ -182,6 +203,38 @@ public class FunctionalVOUtil { return(user); } + public List<GroupVO> createTestCourseGroups(URL deploymentUrl, int count) throws IOException, URISyntaxException{ + RestConnection restConnection = new RestConnection(deploymentUrl); + + restConnection.login(getUsername(), getPassword()); + + List<GroupVO> group = new ArrayList<GroupVO>(); + + for(int i = 0; i < count; i++){ + GroupVO vo = new GroupVO(); + String groupname = ("selgrp_" + i + "_" + UUID.randomUUID().toString()).substring(0, 24); + vo.setName(groupname); + vo.setDescription("group#" + i + " created for selenium test case."); + vo.setType("BuddyGroup"); + vo.setMinParticipants(new Integer(-1)); + vo.setMaxParticipants(new Integer(-1)); + + URI request = UriBuilder.fromUri(deploymentUrl.toURI()).path("restapi").path("groups").build(); + HttpPut method = restConnection.createPut(request, MediaType.APPLICATION_JSON, true); + restConnection.addJsonEntity(method, vo); + + HttpResponse response = restConnection.execute(method); + assertTrue(response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 201); + + vo = restConnection.parse(response, GroupVO.class); + group.add(vo); + } + + restConnection.shutdown(); + + return(group); + } + /** * Imports the specified course via REST. * @@ -225,6 +278,38 @@ public class FunctionalVOUtil { return(vo); } + /** + * + * @param deploymentUrl + * @param courseId + * @param group + * @return + * @throws IOException + * @throws URISyntaxException + */ + public List<GroupVO> addGroupToCourse(URL deploymentUrl, long courseId, List<GroupVO> group) throws IOException, URISyntaxException{ + RestConnection restConnection = new RestConnection(deploymentUrl); + restConnection.login(getUsername(), getPassword()); + + List<GroupVO> newGroup = new ArrayList<GroupVO>(); + + for(GroupVO currentGroup: group){ + URI request = UriBuilder.fromUri(deploymentUrl.toURI()).path("restapi").path("repo").path("courses").path(Long.toString(courseId)).path("groups").build(); + HttpPut method = restConnection.createPut(request, MediaType.APPLICATION_JSON, true); + restConnection.addJsonEntity(method, currentGroup); + + HttpResponse response = restConnection.execute(method); + assertEquals(200, response.getStatusLine().getStatusCode()); + + GroupVO vo = restConnection.parse(response, GroupVO.class); + newGroup.add(vo); + } + + restConnection.shutdown(); + + return(newGroup); + } + /** * * @param deploymentUrl