diff --git a/OpenRobertaServer/src/test/java/de/fhg/iais/roberta/javaServer/basics/restInterface/ExportAllRestTest.java b/OpenRobertaServer/src/test/java/de/fhg/iais/roberta/javaServer/basics/restInterface/ExportAllRestTest.java index 1e527377a1..e0712bece6 100644 --- a/OpenRobertaServer/src/test/java/de/fhg/iais/roberta/javaServer/basics/restInterface/ExportAllRestTest.java +++ b/OpenRobertaServer/src/test/java/de/fhg/iais/roberta/javaServer/basics/restInterface/ExportAllRestTest.java @@ -15,6 +15,7 @@ import de.fhg.iais.roberta.persistence.util.HttpSessionState; import de.fhg.iais.roberta.util.Key; + import static org.junit.Assert.assertNull; public class ExportAllRestTest extends AbstractRestInterfaceTest { @@ -76,15 +77,15 @@ public void checkXmlTest() throws Exception { //check if xml text is correct Assert.assertEquals( - "FALSEprogTextToExportxmlTextToExport" - , - xmlText); + "FALSEprogTextToExportxmlTextToExport" + , + xmlText); } /** @@ -125,7 +126,7 @@ public void groupAndOwnedProgramsTest() throws Exception { //['p5','gp4'] are his calliope Programs List programNames = new ArrayList<>(); ZipEntry ze; - while ( (ze = zin2.getNextEntry()) != null ) { + while ((ze = zin2.getNextEntry()) != null) { programNames.add(ze.getName()); } //this has an order due to it not coming from a HashMap @@ -166,7 +167,7 @@ public void onlyGroupProgramsTest() throws Exception { //check zip entries it should not create the MyGroups Folder ZipEntry ze; - while ( (ze = zin.getNextEntry()) != null ) { + while ((ze = zin.getNextEntry()) != null) { Assert.assertTrue(ze.getName().startsWith("PidsGroup/")); } @@ -185,11 +186,11 @@ public void noProgramsExportTest() throws Exception { //create temporary user without any programs HttpSessionState tempMember = HttpSessionState.initOnlyLegalForDebugging("tempMember", robotPlugins, this.serverProperties, 5); restUser( - tempMember, - "{'cmd':'createUser';'accountName':'tempMember';'userName':'temp';'password':'12';'userEmail':'';'role':'STUDENT'," - + " 'isYoungerThen14': true, 'language': 'de'}", - "ok", - Key.USER_CREATE_SUCCESS); + tempMember, + "{'cmd':'createUser';'accountName':'tempMember';'userName':'temp';'password':'12';'userEmail':'';'role':'STUDENT'," + + " 'isYoungerThen14': true, 'language': 'de'}", + "ok", + Key.USER_CREATE_SUCCESS); restUser(tempMember, "{'cmd':'login';'accountName':'tempMember';'password':'12'}", "ok", Key.USER_GET_ONE_SUCCESS); ZipInputStream zin = exportAllProgramsAsZipInputStream(tempMember); @@ -212,12 +213,14 @@ public void noProgramsExportTest() throws Exception { * */ private void pidAndMinschaCreateSomePrograms() throws Exception { + restClient.setRobot(mkFRR(this.sPid.getInitToken(), "{'cmd':'setRobot'; 'robot':'ev3lejosv1'}")); saveProgramAs(this.sPid, "pid", "pid", "p1", ".1.pid", null, null, "ok", Key.PROGRAM_SAVE_SUCCESS); saveProgramAs(this.sPid, "pid", "pid", "p2", ".2.pid", null, null, "ok", Key.PROGRAM_SAVE_SUCCESS); restClient.setRobot(mkFRR(this.sPid.getInitToken(), "{'cmd':'setRobot'; 'robot':'calliope2017'}")); saveProgramAs(this.sPid, "pid", "pid", "p5", ".1.pid", null, null, "ok", Key.PROGRAM_SAVE_SUCCESS); restClient.setRobot(mkFRR(this.sPid.getInitToken(), "{'cmd':'setRobot'; 'robot':'ev3lejosv1'}")); //Minscha changes config + restClient.setRobot(mkFRR(this.sMinscha.getInitToken(), "{'cmd':'setRobot'; 'robot':'ev3lejosv1'}")); saveProgramAs(this.sMinscha, "minscha", "minscha", "p1", "progTextToExport", null, CONF_PRE + "xmlTextToExport" + CONF_POST, "ok", Key.PROGRAM_SAVE_SUCCESS); } @@ -226,17 +229,19 @@ private void groupSetup() throws Exception { restGroups(this.sPid, "{'cmd':'createUserGroup';'groupName':'PidsGroup';'groupMemberNames':['Member1','Member2'] }", "ok", Key.GROUP_CREATE_SUCCESS); restUser( - this.groupMember1, - "{'cmd':'login';'accountName':'PidsGroup:Member1';'password':'PidsGroup:Member1';'userGroupOwner':'pid';'userGroupName':'PidsGroup' }", - "ok", - Key.USER_GET_ONE_SUCCESS); + this.groupMember1, + "{'cmd':'login';'accountName':'PidsGroup:Member1';'password':'PidsGroup:Member1';'userGroupOwner':'pid';'userGroupName':'PidsGroup' }", + "ok", + Key.USER_GET_ONE_SUCCESS); restUser( - this.groupMember2, - "{'cmd':'login';'accountName':'PidsGroup:Member2';'password':'PidsGroup:Member2';'userGroupOwner':'pid';'userGroupName':'PidsGroup' }", - "ok", - Key.USER_GET_ONE_SUCCESS); + this.groupMember2, + "{'cmd':'login';'accountName':'PidsGroup:Member2';'password':'PidsGroup:Member2';'userGroupOwner':'pid';'userGroupName':'PidsGroup' }", + "ok", + Key.USER_GET_ONE_SUCCESS); + restClient.setRobot(mkFRR(this.groupMember1.getInitToken(), "{'cmd':'setRobot'; 'robot':'ev3lejosv1'}")); + restClient.setRobot(mkFRR(this.groupMember2.getInitToken(), "{'cmd':'setRobot'; 'robot':'ev3lejosv1'}")); //they save some programs saveProgramAs(this.groupMember1, "PidsGroup:Member1", "PidsGroup:Member1", "gp1", ".1.PidsGroup:Member1", null, null, "ok", Key.PROGRAM_SAVE_SUCCESS); saveProgramAs(this.groupMember1, "PidsGroup:Member1", "PidsGroup:Member1", "gp2", ".1.PidsGroup:Member1", null, null, "ok", Key.PROGRAM_SAVE_SUCCESS); @@ -249,7 +254,7 @@ private void groupSetup() throws Exception { private String firstProgramOfZipToString(ZipInputStream uZis) throws IOException { ZipInputStream zis = uZis; - if ( zis == null ) { + if (zis == null) { return null; } StringBuilder resultString = new StringBuilder(); @@ -258,7 +263,7 @@ private String firstProgramOfZipToString(ZipInputStream uZis) throws IOException //get the first program zis.getNextEntry(); //read its contents - while ( (read = zis.read(buffer, 0, 1024)) >= 0 ) { + while ((read = zis.read(buffer, 0, 1024)) >= 0) { resultString.append(new String(buffer, 0, read)); } return resultString.toString(); @@ -266,12 +271,12 @@ private String firstProgramOfZipToString(ZipInputStream uZis) throws IOException private ZipInputStream exportAllProgramsAsZipInputStream(HttpSessionState user) throws Exception { Response reUser = restExportAll(user); - if ( reUser == null ) { + if (reUser == null) { return null; } //check if zip has contentType and name Assert.assertEquals("{Content-Type=[application/zip], Content-Disposition=[attachment; filename=\"NEPO_Programs.zip\"]}", - reUser.getMetadata().toString()); + reUser.getMetadata().toString()); ByteArrayInputStream stream1 = (ByteArrayInputStream) reUser.getEntity(); return new ZipInputStream(stream1); diff --git a/OpenRobertaServer/src/test/java/de/fhg/iais/roberta/javaServer/basics/restInterface/GroupRestTest.java b/OpenRobertaServer/src/test/java/de/fhg/iais/roberta/javaServer/basics/restInterface/GroupRestTest.java index 8e03f4ae11..301d49d7b4 100644 --- a/OpenRobertaServer/src/test/java/de/fhg/iais/roberta/javaServer/basics/restInterface/GroupRestTest.java +++ b/OpenRobertaServer/src/test/java/de/fhg/iais/roberta/javaServer/basics/restInterface/GroupRestTest.java @@ -320,6 +320,10 @@ private void GroupMember1And2LoginAndSavePrograms() throws Exception { Key.USER_GET_ONE_SUCCESS); Assert.assertTrue(this.groupMember1.isUserLoggedIn() && this.groupMember2.isUserLoggedIn()); + + restClient.setRobot(mkFRR(this.groupMember1.getInitToken(), "{'cmd':'setRobot'; 'robot':'ev3lejosv1'}")); + restClient.setRobot(mkFRR(this.groupMember2.getInitToken(), "{'cmd':'setRobot'; 'robot':'ev3lejosv1'}")); + restClient.setRobot(mkFRR(this.sPid.getInitToken(), "{'cmd':'setRobot'; 'robot':'ev3lejosv1'}")); //Member1 saves ev3 Programs saveProgramAs(this.groupMember1, "PidsGroup:Member1", "PidsGroup:Member1", "gp1", ".1.PidsGroup:Member1", null, null, "ok", Key.PROGRAM_SAVE_SUCCESS); saveProgramAs(this.groupMember1, "PidsGroup:Member1", "PidsGroup:Member1", "gp2", ".1.PidsGroup:Member1", null, null, "ok", Key.PROGRAM_SAVE_SUCCESS); diff --git a/OpenRobertaServer/src/test/java/de/fhg/iais/roberta/javaServer/basics/restInterface/ProgramRestTest.java b/OpenRobertaServer/src/test/java/de/fhg/iais/roberta/javaServer/basics/restInterface/ProgramRestTest.java index df912b79c7..e15c4f9f72 100644 --- a/OpenRobertaServer/src/test/java/de/fhg/iais/roberta/javaServer/basics/restInterface/ProgramRestTest.java +++ b/OpenRobertaServer/src/test/java/de/fhg/iais/roberta/javaServer/basics/restInterface/ProgramRestTest.java @@ -21,6 +21,8 @@ public void init() throws Exception { @Test public void programWorkflowTest() throws Exception { + restClient.setRobot(mkFRR(this.sPid.getInitToken(), "{'cmd':'setRobot'; 'robot':'ev3lejosv1'}")); + restClient.setRobot(mkFRR(this.sMinscha.getInitToken(), "{'cmd':'setRobot'; 'robot':'ev3lejosv1'}")); pidCreatesAndUpdates4Programs(); minschaCreates1ConfAnd2Programs(); pidSharesProgramsMinschaCanAccessRW();