Skip to content
Snippets Groups Projects
Commit 380c7d34 authored by Julian Dehne's avatar Julian Dehne
Browse files

bug: fixed problem in mocking

parent f2c22726
No related branches found
No related tags found
No related merge requests found
package unipotsdam.gf.core.database.mysql; package unipotsdam.gf.core.database.mysql;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import unipotsdam.gf.config.GFDatabaseConfig; import unipotsdam.gf.config.GFDatabaseConfig;
import unipotsdam.gf.modules.communication.view.CommunicationView;
import java.sql.*; import java.sql.*;
import java.util.Date; import java.util.Date;
public class MysqlConnect { public class MysqlConnect {
private static final Logger log = LoggerFactory.getLogger(MysqlConnect.class);
public Connection conn = null; public Connection conn = null;
private static String createConnectionString() { private static String createConnectionString() {
...@@ -41,6 +46,7 @@ public class MysqlConnect { ...@@ -41,6 +46,7 @@ public class MysqlConnect {
conn.close(); conn.close();
} }
} catch (final SQLException e) { } catch (final SQLException e) {
log.error(e.toString());
throw new Error("could not close mysql"); throw new Error("could not close mysql");
} }
} }
...@@ -56,6 +62,7 @@ public class MysqlConnect { ...@@ -56,6 +62,7 @@ public class MysqlConnect {
} }
return ps; return ps;
} catch (SQLException ex) { } catch (SQLException ex) {
log.error(ex.toString());
System.out.println(ex); System.out.println(ex);
} }
return null; return null;
...@@ -68,6 +75,7 @@ public class MysqlConnect { ...@@ -68,6 +75,7 @@ public class MysqlConnect {
ResultSet queryResult = ps.executeQuery(); ResultSet queryResult = ps.executeQuery();
return new VereinfachtesResultSet(queryResult); return new VereinfachtesResultSet(queryResult);
} catch (SQLException ex) { } catch (SQLException ex) {
log.error(ex.toString());
System.out.println(ex); System.out.println(ex);
} }
return null; return null;
...@@ -78,6 +86,7 @@ public class MysqlConnect { ...@@ -78,6 +86,7 @@ public class MysqlConnect {
try { try {
this.conn.createStatement().execute(statement); this.conn.createStatement().execute(statement);
} catch (SQLException ex) { } catch (SQLException ex) {
log.error(ex.toString());
System.out.println(ex); System.out.println(ex);
} }
} }
...@@ -88,6 +97,7 @@ public class MysqlConnect { ...@@ -88,6 +97,7 @@ public class MysqlConnect {
try { try {
return ps.executeUpdate(); return ps.executeUpdate();
} catch (SQLException ex) { } catch (SQLException ex) {
log.error(ex.toString());
System.out.println(ex); System.out.println(ex);
} }
return null; return null;
...@@ -99,6 +109,8 @@ public class MysqlConnect { ...@@ -99,6 +109,8 @@ public class MysqlConnect {
try { try {
ps.execute(); ps.execute();
} catch (SQLException ex) { } catch (SQLException ex) {
log.error(ex.toString());
System.out.println(ex); System.out.println(ex);
} }
} }
......
package unipotsdam.gf.modules.researchreport; package unipotsdam.gf.modules.researchreport;
import sun.reflect.generics.reflectiveObjects.NotImplementedException; import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import uk.co.jemos.podam.api.PodamFactory;
import uk.co.jemos.podam.api.PodamFactoryImpl;
import unipotsdam.gf.core.management.project.Project; import unipotsdam.gf.core.management.project.Project;
import unipotsdam.gf.core.management.user.User; import unipotsdam.gf.core.management.user.User;
import java.io.File; import java.io.File;
public class DummyResearchReportManagement implements ResearchReportManagement { public class DummyResearchReportManagement implements ResearchReportManagement {
/**
* Utility to creaty dummy data for students
*/
PodamFactory factory = new PodamFactoryImpl();
@Override @Override
public String createResearchReport( public String createResearchReport(
ResearchReport researchReport, Project project, User student) { ResearchReport researchReport, Project project, User student) {
throw new NotImplementedException(); return factory.manufacturePojo(ResearchReport.class).getId();
} }
@Override @Override
......
...@@ -6,7 +6,7 @@ public class ResearchReport { ...@@ -6,7 +6,7 @@ public class ResearchReport {
// TODO add properties // TODO add properties
private String title; private String title;
private ResearchQuestion researchQuestion; private ResearchQuestion researchQuestion;
private String id;
private List<String> learningGoals; private List<String> learningGoals;
private String method; private String method;
private String research; private String research;
...@@ -108,4 +108,12 @@ public class ResearchReport { ...@@ -108,4 +108,12 @@ public class ResearchReport {
public void setTimeplan(Timeplanning timeplan) { public void setTimeplan(Timeplanning timeplan) {
this.timeplan = timeplan; this.timeplan = timeplan;
} }
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
} }
...@@ -6,6 +6,7 @@ import org.junit.Before; ...@@ -6,6 +6,7 @@ import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoJUnitRunner; import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.MockitoRule; import org.mockito.junit.MockitoRule;
...@@ -47,7 +48,7 @@ public class ActivityFlowTest { ...@@ -47,7 +48,7 @@ public class ActivityFlowTest {
@Inject @Inject
ResearchReportManagement researchReportManagement; ResearchReportManagement researchReportManagement;
@Inject @Mock
Feedback feedback; Feedback feedback;
@Inject @Inject
...@@ -174,17 +175,10 @@ public class ActivityFlowTest { ...@@ -174,17 +175,10 @@ public class ActivityFlowTest {
public void createCourse() { public void createCourse() {
// add Titel // add Titel
Project project = new Project(); Project project = factory.manufacturePojo(Project.class);
project.setId("testprojekt");
management.create(project); management.create(project);
// select criteria, topics, phases, assessment criteria ProjectConfiguration projectConfiguration = factory.manufacturePojo(ProjectConfiguration.class);
HashMap<ProjectPhase, Boolean> phasesSelected = new HashMap<>();
HashMap<Category, Boolean> criteriaSelected = new HashMap<>();
HashMap<AssessmentMechanism, Boolean> assessemtsSelected = new HashMap<>();
HashMap<GroupFormationMechanism, Boolean> groupFormationSelected = new HashMap<>();
ProjectConfiguration projectConfiguration = new ProjectConfiguration(phasesSelected, criteriaSelected,
assessemtsSelected, groupFormationSelected);
management.create(projectConfiguration, project); management.create(projectConfiguration, project);
// //
......
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