Skip to content
Snippets Groups Projects
Commit abc34716 authored by Martin Staehr's avatar Martin Staehr Committed by Julian Dehne
Browse files

Merge remote-tracking branch 'origin/integrating_martins_module_#8' into...

Merge remote-tracking branch 'origin/integrating_martins_module_#8' into integrating_martins_module_#8
parents 2ac6d213 dc695505
No related branches found
No related tags found
No related merge requests found
Showing
with 112 additions and 109 deletions
...@@ -10,4 +10,5 @@ public class GFDatabaseConfig { ...@@ -10,4 +10,5 @@ public class GFDatabaseConfig {
public static final String USER = "root"; public static final String USER = "root";
public static final String PASS = ""; public static final String PASS = "";
public static final String DB_NAME = "fltrail"; public static final String DB_NAME = "fltrail";
public static final String TEST_DB_NAME = "fltrail_test";
} }
...@@ -76,7 +76,8 @@ public class CommunicationService implements ICommunication { ...@@ -76,7 +76,8 @@ public class CommunicationService implements ICommunication {
isUpdated = true; isUpdated = true;
} else { } else {
return isUpdated; return isUpdated;
} return null; }
return null;
} }
...@@ -84,7 +85,8 @@ public class CommunicationService implements ICommunication { ...@@ -84,7 +85,8 @@ public class CommunicationService implements ICommunication {
if (isUpdated == null) { if (isUpdated == null) {
} else { } else {
isUpdated = false; isUpdated = false;
} return null; }
return null;
} }
@Override @Override
...@@ -122,8 +124,7 @@ public class CommunicationService implements ICommunication { ...@@ -122,8 +124,7 @@ public class CommunicationService implements ICommunication {
HttpEntity entity = body.getEntity(); HttpEntity entity = body.getEntity();
HttpResponse<Map> response = HttpResponse<Map> response = body.asObject(Map.class);
body.asObject(Map.class);
if (isBadRequest(response)) { if (isBadRequest(response)) {
return Strings.EMPTY; return Strings.EMPTY;
...@@ -145,6 +146,9 @@ public class CommunicationService implements ICommunication { ...@@ -145,6 +146,9 @@ public class CommunicationService implements ICommunication {
// chatRoom name: projectId - GroupId // chatRoom name: projectId - GroupId
String chatRoomName = String.join("-", group.getProjectName(), String.valueOf(group.getId())); String chatRoomName = String.join("-", group.getProjectName(), String.valueOf(group.getId()));
if (exists(chatRoomName)) {
return true;
}
String chatRoomId = createChatRoom(chatRoomName, readOnly, group.getMembers()); String chatRoomId = createChatRoom(chatRoomName, readOnly, group.getMembers());
if (chatRoomId.isEmpty()) { if (chatRoomId.isEmpty()) {
return false; return false;
...@@ -164,10 +168,7 @@ public class CommunicationService implements ICommunication { ...@@ -164,10 +168,7 @@ public class CommunicationService implements ICommunication {
bodyMap.put("roomId", roomId); bodyMap.put("roomId", roomId);
HttpResponse<Map> response = HttpResponse<Map> response =
unirestService unirestService.post(ROCKET_CHAT_API_LINK + "groups.delete").headers(headerMap).body(bodyMap)
.post(ROCKET_CHAT_API_LINK + "groups.delete")
.headers(headerMap)
.body(bodyMap)
.asObject(Map.class); .asObject(Map.class);
if (isBadRequest(response)) { if (isBadRequest(response)) {
...@@ -205,11 +206,9 @@ public class CommunicationService implements ICommunication { ...@@ -205,11 +206,9 @@ public class CommunicationService implements ICommunication {
String groupUrl = addUser ? "groups.invite" : "groups.kick"; String groupUrl = addUser ? "groups.invite" : "groups.kick";
HttpResponse<Map> response = unirestService HttpResponse<Map> response =
.post(GFRocketChatConfig.ROCKET_CHAT_API_LINK + groupUrl) unirestService.post(GFRocketChatConfig.ROCKET_CHAT_API_LINK + groupUrl).headers(headerMap).body(bodyMap)
.headers(headerMap) .asObject(Map.class);
.body(bodyMap)
.asObject(Map.class);
if (isBadRequest(response)) { if (isBadRequest(response)) {
return false; return false;
...@@ -232,11 +231,8 @@ public class CommunicationService implements ICommunication { ...@@ -232,11 +231,8 @@ public class CommunicationService implements ICommunication {
Map<String, String> headerMap = new RocketChatHeaderMapBuilder().withRocketChatAdminAuth().build(); Map<String, String> headerMap = new RocketChatHeaderMapBuilder().withRocketChatAdminAuth().build();
HttpResponse<Map> response = HttpResponse<Map> response = unirestService.get(ROCKET_CHAT_API_LINK + "groups.info").headers(headerMap)
unirestService .queryString("roomId", roomId).asObject(Map.class);
.get(ROCKET_CHAT_API_LINK + "groups.info")
.headers(headerMap)
.queryString("roomId", roomId).asObject(Map.class);
if (isBadRequest(response)) { if (isBadRequest(response)) {
return Strings.EMPTY; return Strings.EMPTY;
...@@ -263,9 +259,7 @@ public class CommunicationService implements ICommunication { ...@@ -263,9 +259,7 @@ public class CommunicationService implements ICommunication {
rocketChatAuth.put("password", user.getPassword()); rocketChatAuth.put("password", user.getPassword());
HttpResponse<RocketChatLoginResponse> response = HttpResponse<RocketChatLoginResponse> response =
unirestService unirestService.post(ROCKET_CHAT_API_LINK + "login").body(rocketChatAuth)
.post(ROCKET_CHAT_API_LINK + "login")
.body(rocketChatAuth)
.asObject(RocketChatLoginResponse.class); .asObject(RocketChatLoginResponse.class);
if (isBadRequest(response)) { if (isBadRequest(response)) {
...@@ -298,9 +292,7 @@ public class CommunicationService implements ICommunication { ...@@ -298,9 +292,7 @@ public class CommunicationService implements ICommunication {
rocketChatRegister.put("name", user.getName()); rocketChatRegister.put("name", user.getName());
HttpResponse<RocketChatRegisterResponse> response = HttpResponse<RocketChatRegisterResponse> response =
unirestService unirestService.post(ROCKET_CHAT_API_LINK + "users.register").body(rocketChatRegister)
.post(ROCKET_CHAT_API_LINK + "users.register")
.body(rocketChatRegister)
.asObject(RocketChatRegisterResponse.class); .asObject(RocketChatRegisterResponse.class);
if (isBadRequest(response)) { if (isBadRequest(response)) {
...@@ -327,7 +319,6 @@ public class CommunicationService implements ICommunication { ...@@ -327,7 +319,6 @@ public class CommunicationService implements ICommunication {
loginUser(ADMIN_USER); loginUser(ADMIN_USER);
User user = userDAO.getUserByEmail(userEmail);
String chatRoomId = groupDAO.getGroupChatRoomId(new User(userEmail), new Project(projectName)); String chatRoomId = groupDAO.getGroupChatRoomId(new User(userEmail), new Project(projectName));
if (chatRoomId.isEmpty()) { if (chatRoomId.isEmpty()) {
return Strings.EMPTY; return Strings.EMPTY;
...@@ -392,10 +383,8 @@ public class CommunicationService implements ICommunication { ...@@ -392,10 +383,8 @@ public class CommunicationService implements ICommunication {
@Override @Override
public boolean sendMessageToUsers(Project project, EMailMessage eMailMessage) { public boolean sendMessageToUsers(Project project, EMailMessage eMailMessage) {
List<User> users = userDAO.getUsersByProjectName(project.getName()); List<User> users = userDAO.getUsersByProjectName(project.getName());
List<User> userEmailProblemList = users List<User> userEmailProblemList =
.stream() users.stream().filter(user -> !sendSingleMessage(eMailMessage, user)).collect(Collectors.toList());
.filter(user -> !sendSingleMessage(eMailMessage, user))
.collect(Collectors.toList());
return userEmailProblemList.isEmpty(); return userEmailProblemList.isEmpty();
} }
...@@ -450,14 +439,13 @@ public class CommunicationService implements ICommunication { ...@@ -450,14 +439,13 @@ public class CommunicationService implements ICommunication {
user.setRocketChatPersonalAccessToken(responseBody.get("token").toString()); user.setRocketChatPersonalAccessToken(responseBody.get("token").toString());
return true; return true;
}*/ }*/
private boolean isBadRequest(HttpResponse response) { private boolean isBadRequest(HttpResponse response) {
int status = response.getStatus(); int status = response.getStatus();
if (Response.Status.UNAUTHORIZED.getStatusCode() == status) { if (Response.Status.UNAUTHORIZED.getStatusCode() == status) {
unsetAdminToken(); unsetAdminToken();
} }
return status == Response.Status.BAD_REQUEST.getStatusCode() || return status == Response.Status.BAD_REQUEST.getStatusCode() || status == Response.Status.UNAUTHORIZED
status == Response.Status.UNAUTHORIZED.getStatusCode(); .getStatusCode();
} }
......
...@@ -155,9 +155,12 @@ public class GroupDAO { ...@@ -155,9 +155,12 @@ public class GroupDAO {
public String getGroupChatRoomId(User user, Project project) { public String getGroupChatRoomId(User user, Project project) {
connect.connect(); connect.connect();
String mysqlRequest = "SELECT g.chatRoomId FROM groups g join groupuser gu on g.id=gu.groupId where g" + StringBuilder stringBuilder = new StringBuilder();
".projectName=? and gu.studentId=?"; stringBuilder.append("SELECT g.chatRoomId FROM groups g ");
VereinfachtesResultSet resultSet = connect.issueSelectStatement(mysqlRequest, project.getName(), stringBuilder.append("join groupuser gu on g.id=gu.groupId ");
stringBuilder.append("where g.projectName=? and gu.userEmail=?");
VereinfachtesResultSet resultSet = connect.issueSelectStatement(stringBuilder.toString(), project.getName(),
user.getEmail()); user.getEmail());
if (Objects.isNull(resultSet)) { if (Objects.isNull(resultSet)) {
connect.close(); connect.close();
......
...@@ -22,19 +22,9 @@ public class Project { ...@@ -22,19 +22,9 @@ public class Project {
private String[] tags; private String[] tags;
public Project() { public Project() {
tags = new String[0];
} }
public Project(String name, String password, Boolean active, String author, String adminPassword, String[] tags) {
this.name = name;
this.password = password;
this.active = active;
this.authorEmail = author;
this.adminPassword = adminPassword;
this.timecreated = System.currentTimeMillis();
// default starting at course creation if new
this.setPhase(Phase.CourseCreation);
this.tags = tags;
}
public Project( public Project(
String name, String password, Boolean active, Long timecreated, String authorEmail, String name, String password, Boolean active, Long timecreated, String authorEmail,
...@@ -49,13 +39,17 @@ public class Project { ...@@ -49,13 +39,17 @@ public class Project {
this.tags = tags; this.tags = tags;
} }
public Project(String projectName, String password) { public Project(String projectName, String authorEmail) {
this.name = projectName; this.name = projectName;
this.password = password; this.authorEmail = authorEmail;
this.active = true;
this.timecreated = System.currentTimeMillis();
tags = new String[0];
} }
public Project(String projectName) { public Project(String projectName) {
this.name = projectName; this.name = projectName;
this.active = true;
} }
......
...@@ -43,7 +43,7 @@ public class ProjectDAO { ...@@ -43,7 +43,7 @@ public class ProjectDAO {
"INSERT INTO projects (`name`, `password`, `active`, `timecreated`, `author`, " + "`adminPassword`, `phase`) values (?,?,?,?,?,?,?)"; "INSERT INTO projects (`name`, `password`, `active`, `timecreated`, `author`, " + "`adminPassword`, `phase`) values (?,?,?,?,?,?,?)";
connect.issueInsertOrDeleteStatement(mysqlRequest, project.getName(), project.getPassword(), connect.issueInsertOrDeleteStatement(mysqlRequest, project.getName(), project.getPassword(),
project.isActive(), project.getTimecreated(), project.getAuthorEmail(), project.getAdminPassword(), project.isActive(), project.getTimecreated(), project.getAuthorEmail(), project.getAdminPassword(),
project.getPhase() == null ? Phase.CourseCreation : project.getPhase()); project.getPhase() == null ? Phase.GroupFormation : project.getPhase());
connect.close(); connect.close();
......
package unipotsdam.gf.process.phases; package unipotsdam.gf.process.phases;
public enum Phase { public enum Phase {
CourseCreation, GroupFormation, DossierFeedback, Execution, Assessment, GroupFormation, DossierFeedback, Execution, Assessment,
Projectfinished Projectfinished
} }
...@@ -75,11 +75,6 @@ public class PhasesImpl implements IPhases { ...@@ -75,11 +75,6 @@ public class PhasesImpl implements IPhases {
Phase changeToPhase = getNextPhase(currentPhase); Phase changeToPhase = getNextPhase(currentPhase);
Map<StudentIdentifier, ConstraintsMessages> tasks; Map<StudentIdentifier, ConstraintsMessages> tasks;
switch (currentPhase) { switch (currentPhase) {
case CourseCreation:
// saving the state
saveState(project, changeToPhase);
break;
case GroupFormation: case GroupFormation:
// inform users about the formed groups, optionally giving them a hint on what happens next // inform users about the formed groups, optionally giving them a hint on what happens next
iCommunication.sendMessageToUsers(project, Messages.GroupFormation(project)); iCommunication.sendMessageToUsers(project, Messages.GroupFormation(project));
...@@ -126,8 +121,6 @@ public class PhasesImpl implements IPhases { ...@@ -126,8 +121,6 @@ public class PhasesImpl implements IPhases {
private Phase getNextPhase(Phase phase) { private Phase getNextPhase(Phase phase) {
switch (phase) { switch (phase) {
case CourseCreation:
return Phase.GroupFormation;
case GroupFormation: case GroupFormation:
return Phase.DossierFeedback; return Phase.DossierFeedback;
case DossierFeedback: case DossierFeedback:
......
package unipotsdam.gf.modules.communication; package unipotsdam.gf.taglibs;
import org.glassfish.hk2.api.ServiceLocator; import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.utilities.ServiceLocatorUtilities; import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
...@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory; ...@@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory;
import unipotsdam.gf.config.GFApplicationBinder; import unipotsdam.gf.config.GFApplicationBinder;
import unipotsdam.gf.interfaces.ICommunication; import unipotsdam.gf.interfaces.ICommunication;
import unipotsdam.gf.modules.communication.service.CommunicationService; import unipotsdam.gf.modules.communication.service.CommunicationService;
import unipotsdam.gf.session.GFContexts;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.JspWriter;
...@@ -27,11 +28,12 @@ public class ChatWindow extends SimpleTagSupport { ...@@ -27,11 +28,12 @@ public class ChatWindow extends SimpleTagSupport {
PageContext pageContext = (PageContext) getJspContext(); PageContext pageContext = (PageContext) getJspContext();
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
String token = request.getParameter("token"); /*String token = request.getParameter("token"); */
String projectId = request.getParameter("projectId"); String projectId = request.getParameter("projectName");
ICommunication communicationService = new CommunicationService(); ICommunication communicationService = new CommunicationService();
String chatRoomLink = communicationService.getChatRoomLink(token, projectId); String chatRoomLink = communicationService.getChatRoomLink(request.getSession().getAttribute(GFContexts
.USEREMAIL).toString(), projectId);
log.debug("ChatRoomLink for ChatWindow: {}", chatRoomLink); log.debug("ChatRoomLink for ChatWindow: {}", chatRoomLink);
JspWriter out = getJspContext().getOut(); JspWriter out = getJspContext().getOut();
out.println("<iframe height=\"400px\" src=\"" + chatRoomLink + "\"/>"); out.println("<iframe height=\"400px\" src=\"" + chatRoomLink + "\"/>");
......
...@@ -96,15 +96,6 @@ public class Menu extends SimpleTagSupport { ...@@ -96,15 +96,6 @@ public class Menu extends SimpleTagSupport {
" <ul>\n"; " <ul>\n";
if (phase != null) if (phase != null)
switch (phase) { switch (phase) {
case CourseCreation: {
phaseViewString += " <li class=\"neutral icon\">Projektinitialisierung</li>\n" +
" <li class=\"icon inactive\">Entwurfsphase</li>\n" +
" <li class=\"icon inactive\">Feedbackphase</li>\n" +
" <li class=\"icon inactive\">Reflextionsphase</li>\n" +
" <li class=\"icon inactive\" >Assessment</li>\n" +
" <li class=\"icon inactive\">Noten</li>\n";
break;
}
case GroupFormation:{ case GroupFormation:{
phaseViewString += " <li class=\"neutral icon closed\">Projektinitialisierung</li>\n" + phaseViewString += " <li class=\"neutral icon closed\">Projektinitialisierung</li>\n" +
" <li class=\"draft icon \">Entwurfsphase</li>\n" + " <li class=\"draft icon \">Entwurfsphase</li>\n" +
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
<%@ taglib uri="../taglibs/gemeinsamForschen.tld" prefix="headLine" %> <%@ taglib uri="../taglibs/gemeinsamForschen.tld" prefix="headLine" %>
<%@ taglib uri="../taglibs/gemeinsamForschen.tld" prefix="omniDependencies" %> <%@ taglib uri="../taglibs/gemeinsamForschen.tld" prefix="omniDependencies" %>
<%@ taglib uri="../taglibs/gemeinsamForschen.tld" prefix="footer" %> <%@ taglib uri="../taglibs/gemeinsamForschen.tld" prefix="footer" %>
<%@ taglib uri="../taglibs/gemeinsamForschen.tld" prefix="chat"%>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="de"> <html lang="de">
<head> <head>
...@@ -51,9 +53,10 @@ ...@@ -51,9 +53,10 @@
<div style="clear:left"></div> <div style="clear:left"></div>
</div> </div>
</div> </div>
</script>
<chat:chatWindow orientation="right"></chat:chatWindow>
</script>
</div> </div>
<footer:footer/> <footer:footer/>
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
<tag> <tag>
<name>chatWindow</name> <name>chatWindow</name>
<tag-class>unipotsdam.gf.modules.communication.ChatWindow</tag-class> <tag-class>unipotsdam.gf.taglibs.ChatWindow</tag-class>
<body-content>empty</body-content> <body-content>empty</body-content>
<attribute> <attribute>
<name>orientation</name> <name>orientation</name>
......
...@@ -13,7 +13,8 @@ public class MysqlTestConnect extends MysqlConnectImpl { ...@@ -13,7 +13,8 @@ public class MysqlTestConnect extends MysqlConnectImpl {
private static String createConnectionString() { private static String createConnectionString() {
String connString = String connString =
"jdbc:mysql://" + "localhost" + "/" + GFDatabaseConfig.DB_NAME + "?user=" + GFDatabaseConfig.USER + "&password=" + GFDatabaseConfig.PASS; "jdbc:mysql://" + "localhost" + "/" + GFDatabaseConfig.TEST_DB_NAME + "?user=" + GFDatabaseConfig.USER +
"&password=" + GFDatabaseConfig.PASS;
return String.format(connString, "fltrail_test"); return String.format(connString, "fltrail_test");
} }
......
...@@ -16,7 +16,8 @@ public class UpdateDB { ...@@ -16,7 +16,8 @@ public class UpdateDB {
private boolean stopOnError; private boolean stopOnError;
private boolean autoCommit; private boolean autoCommit;
private PrintWriter logWriter = new PrintWriter(System.out); //private PrintWriter logWriter = new PrintWriter(System.out);
private PrintWriter logWriter = null;
private PrintWriter errorLogWriter = new PrintWriter(System.err); private PrintWriter errorLogWriter = new PrintWriter(System.err);
private String delimiter = DEFAULT_DELIMITER; private String delimiter = DEFAULT_DELIMITER;
...@@ -29,10 +30,22 @@ public class UpdateDB { ...@@ -29,10 +30,22 @@ public class UpdateDB {
UpdateDB updateDB = new UpdateDB(connection, true, false); UpdateDB updateDB = new UpdateDB(connection, true, false);
System.out.println(new java.io.File( "." ).getCanonicalPath()); System.out.println(new java.io.File( "." ).getCanonicalPath());
updateDB.runScript(new FileReader("src/test/resources/database/db.sql"));
updateDB.runScript(new FileReader("src/test/resources/database/fltrail.sql")); updateDB.runScript(new FileReader("src/test/resources/database/fltrail.sql"));
updateDB.runScript(new FileReader("src/test/resources/database/testuser.sql")); updateDB.runScript(new FileReader("src/test/resources/database/testuser.sql"));
} }
public static void updateTestDB() throws SQLException, ManagedProcessException, IOException {
MysqlConnect mysqlConnect = new MysqlTestConnect();
Connection connection = mysqlConnect.getConnection();
UpdateDB updateDB = new UpdateDB(connection, true, false);
System.out.println(new java.io.File( "." ).getCanonicalPath());
updateDB.runScript(new FileReader("src/test/resources/database/test_db.sql"));
updateDB.runScript(new FileReader("src/test/resources/database/fltrail.sql"));
//updateDB.runScript(new FileReader("src/test/resources/database/testuser.sql"));
}
public UpdateDB(Connection connection, boolean stopOnError, boolean autoCommit) { public UpdateDB(Connection connection, boolean stopOnError, boolean autoCommit) {
this.connection = connection; this.connection = connection;
this.stopOnError = stopOnError; this.stopOnError = stopOnError;
......
...@@ -119,7 +119,7 @@ public class ActivityFlowTest { ...@@ -119,7 +119,7 @@ public class ActivityFlowTest {
formGroups(); formGroups();
// end first phase // end first phase
phases.endPhase(Phase.CourseCreation, project); phases.endPhase(Phase.GroupFormation, project);
// upload dossiers // upload dossiers
uploadDossiers(); uploadDossiers();
......
...@@ -48,12 +48,7 @@ public class PhaseTest { ...@@ -48,12 +48,7 @@ public class PhaseTest {
management.register(user, project, null); management.register(user, project, null);
} }
@Test
public void phase1() {
Project project = new Project();
project.setName(projectName);
phases.endPhase(Phase.CourseCreation, project);
}
@Test @Test
public void phase2() { public void phase2() {
......
package unipotsdam.gf.modules.communication.service; package unipotsdam.gf.modules.communication.service;
import ch.vorburger.exec.ManagedProcessException;
import org.glassfish.hk2.api.ServiceLocator; import org.glassfish.hk2.api.ServiceLocator;
import org.glassfish.hk2.utilities.ServiceLocatorUtilities; import org.glassfish.hk2.utilities.ServiceLocatorUtilities;
import org.junit.After; import org.junit.*;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import uk.co.jemos.podam.api.PodamFactory; import uk.co.jemos.podam.api.PodamFactory;
import uk.co.jemos.podam.api.PodamFactoryImpl; import uk.co.jemos.podam.api.PodamFactoryImpl;
import unipotsdam.gf.config.GFApplicationBinder; import unipotsdam.gf.config.GFApplicationBinder;
import unipotsdam.gf.core.database.TestGFApplicationBinder;
import unipotsdam.gf.core.database.UpdateDB;
import unipotsdam.gf.interfaces.ICommunication; import unipotsdam.gf.interfaces.ICommunication;
import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier; import unipotsdam.gf.modules.assessment.controller.model.StudentIdentifier;
import unipotsdam.gf.modules.communication.model.EMailMessage; import unipotsdam.gf.modules.communication.model.EMailMessage;
...@@ -24,6 +24,8 @@ import unipotsdam.gf.process.constraints.Constraints; ...@@ -24,6 +24,8 @@ import unipotsdam.gf.process.constraints.Constraints;
import unipotsdam.gf.process.constraints.ConstraintsMessages; import unipotsdam.gf.process.constraints.ConstraintsMessages;
import javax.inject.Inject; import javax.inject.Inject;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
...@@ -60,14 +62,21 @@ public class CommunicationServiceTest { ...@@ -60,14 +62,21 @@ public class CommunicationServiceTest {
Management management; Management management;
@BeforeClass
public static void init() throws IOException, SQLException, ManagedProcessException {
UpdateDB.updateTestDB();
}
@Before @Before
public void setUp() { public void setUp() {
//final ServiceLocator locator = ServiceLocatorUtilities.bind(new TestGFApplicationBinder()); final ServiceLocator locator = ServiceLocatorUtilities.bind(new TestGFApplicationBinder());
final ServiceLocator locator = ServiceLocatorUtilities.bind(new GFApplicationBinder()); //final ServiceLocator locator = ServiceLocatorUtilities.bind(new GFApplicationBinder());
locator.inject(this); locator.inject(this);
user = new User("Vorname Nachname", "password", "email@uni.de", true); user = new User("Vorname Nachname", "password", "email@uni.de", true);
userDAO.persist(user, null);
createdChatRooms = new ArrayList<>(); createdChatRooms = new ArrayList<>();
} }
...@@ -76,6 +85,8 @@ public class CommunicationServiceTest { ...@@ -76,6 +85,8 @@ public class CommunicationServiceTest {
public void tearDown() { public void tearDown() {
createdChatRooms.forEach(createdChatRoom -> iCommunication.deleteChatRoom(createdChatRoom)); createdChatRooms.forEach(createdChatRoom -> iCommunication.deleteChatRoom(createdChatRoom));
createdChatRooms.clear(); createdChatRooms.clear();
} }
@Test @Test
...@@ -135,10 +146,8 @@ public class CommunicationServiceTest { ...@@ -135,10 +146,8 @@ public class CommunicationServiceTest {
Group group = new Group(); Group group = new Group();
group.setMembers(Collections.singletonList(ADMIN_USER)); group.setMembers(Collections.singletonList(ADMIN_USER));
group.setProjectName("chatWithGroup"); group.setProjectName("chatWithGroup");
group.setId(1);
boolean successful = iCommunication.createChatRoom(group, false); boolean successful = iCommunication.createChatRoom(group, false);
assertTrue(successful); assertTrue(successful);
createdChatRooms.add(group.getChatRoomId()); createdChatRooms.add(group.getChatRoomId());
} }
...@@ -161,9 +170,11 @@ public class CommunicationServiceTest { ...@@ -161,9 +170,11 @@ public class CommunicationServiceTest {
@Test @Test
public void getChatRoomLink() { public void getChatRoomLink() {
String projectId = "Projekt"; String projectId = "Projekt";
Project project = new Project(projectId, user.getEmail());
projectDAO.persist(project);
Group group = new Group(); Group group = new Group();
userDAO.persist(ADMIN_USER, new UserProfile()); userDAO.persist(ADMIN_USER, new UserProfile());
group.setProjectName(projectId); group.setProjectName(projectId);
group.setMembers(Collections.singletonList(ADMIN_USER)); group.setMembers(Collections.singletonList(ADMIN_USER));
groupDAO.persist(group); groupDAO.persist(group);
......
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
DROP DATABASE `fltrail`;
CREATE DATABASE IF NOT EXISTS `fltrail` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `fltrail`;
\ No newline at end of file
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
DROP DATABASE `fltrail`;
CREATE DATABASE IF NOT EXISTS `fltrail` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `fltrail`;
CREATE TABLE `annotations` ( CREATE TABLE `annotations` (
`id` varchar(120) NOT NULL, `id` varchar(120) NOT NULL,
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
...@@ -85,12 +75,12 @@ CREATE TABLE `phasesselected` ( ...@@ -85,12 +75,12 @@ CREATE TABLE `phasesselected` (
CREATE TABLE `projects` ( CREATE TABLE `projects` (
`name` varchar(100) NOT NULL, `name` varchar(100) NOT NULL,
`password` varchar(400) NOT NULL, `password` varchar(400) DEFAULT '',
`active` tinyint(1) NOT NULL, `active` tinyint(1) NOT NULL DEFAULT true,
`timecreated` mediumtext NOT NULL, `timecreated` mediumtext,
`author` varchar(100) NOT NULL, `author` varchar(100) NOT NULL,
`adminPassword` varchar(400) NOT NULL, `adminPassword` varchar(400),
`phase` varchar(400) NOT NULL `phase` varchar(400) NOT NULL DEFAULT 'GroupFormation'
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `projectuser` ( CREATE TABLE `projectuser` (
...@@ -145,10 +135,10 @@ CREATE TABLE `users` ( ...@@ -145,10 +135,10 @@ CREATE TABLE `users` (
`name` varchar(100) NOT NULL, `name` varchar(100) NOT NULL,
`password` varchar(200) NOT NULL, `password` varchar(200) NOT NULL,
`email` varchar(255) NOT NULL, `email` varchar(255) NOT NULL,
`rocketChatUserId` varchar(400) NOT NULL, `rocketChatUserId` varchar(400),
`rocketChatPersonalAccessToken` varchar(400) NOT NULL, `rocketChatPersonalAccessToken` varchar(400),
`rocketChatUsername` varchar(400) NOT NULL, `rocketChatUsername` varchar(400),
`rocketChatAuthToken` varchar(800) NOT NULL, `rocketChatAuthToken` varchar(800),
`isStudent` tinyint(1) DEFAULT '1' `isStudent` tinyint(1) DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
......
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
DROP DATABASE `fltrail_test`;
CREATE DATABASE IF NOT EXISTS `fltrail_test` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `fltrail_test`;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment