Permalink
Browse files

Move Gatekeeper into Context

  • Loading branch information...
1 parent 87c567f commit 72724e5b42d359005ec8dbfd2c3d01448982c2d4 @unclebob unclebob committed Jul 16, 2014
@@ -3,3 +3,5 @@
|library|
|codecast presentation|
+
+|Fixture setup|
@@ -4,4 +4,5 @@
public static UserGateway userGateway;
public static CodecastGateway codecastGateway;
public static LicenseGateway licenseGateway;
+ public static GateKeeper gateKeeper;
}
@@ -21,7 +21,7 @@
@Before
public void setUp() {
- TestSetup.addInMemoryGatewaysToContext();
+ TestSetup.setupContext();
user = Context.userGateway.save(new User("User"));
useCase = new PresentCodecastUseCase();
}
@@ -1,14 +1,16 @@
package cleancoderscom.tests;
import cleancoderscom.Context;
+import cleancoderscom.GateKeeper;
import cleancoderscom.tests.doubles.InMemoryCodecastGateway;
import cleancoderscom.tests.doubles.InMemoryLicenseGateway;
import cleancoderscom.tests.doubles.InMemoryUserGateway;
public class TestSetup {
- public static void addInMemoryGatewaysToContext() {
+ public static void setupContext() {
Context.userGateway = new InMemoryUserGateway();
Context.licenseGateway = new InMemoryLicenseGateway();
Context.codecastGateway = new InMemoryCodecastGateway();
+ Context.gateKeeper = new GateKeeper();
}
}
@@ -11,10 +11,9 @@
public class CodecastPresentation {
private PresentCodecastUseCase useCase = new PresentCodecastUseCase();
- public static GateKeeper gateKeeper = new GateKeeper();
public CodecastPresentation() {
- TestSetup.addInMemoryGatewaysToContext();
+ TestSetup.setupContext();
}
public boolean addUser(String username) {
@@ -25,7 +24,7 @@ public boolean addUser(String username) {
public boolean loginUser(String username) {
User user = Context.userGateway.findUserByName(username);
if (user != null) {
- gateKeeper.setLoggedInUser(user);
+ Context.gateKeeper.setLoggedInUser(user);
return true;
} else {
return false;
@@ -49,7 +48,7 @@ public boolean createLicenseForDownloading(String username, String codecastTitle
}
public String presentationUser() {
- return gateKeeper.getLoggedInUser().getUserName();
+ return Context.gateKeeper.getLoggedInUser().getUserName();
}
public boolean clearCodecasts() {
@@ -61,7 +60,7 @@ public boolean clearCodecasts() {
}
public int countOfCodecastsPresented() {
- List<PresentableCodecast> presentations = useCase.presentCodecasts(gateKeeper.getLoggedInUser());
+ List<PresentableCodecast> presentations = useCase.presentCodecasts(Context.gateKeeper.getLoggedInUser());
return presentations.size();
}
}
@@ -0,0 +1,9 @@
+package cleancoderscom.tests.fixtures;
+
+import cleancoderscom.tests.TestSetup;
+
+public class FixtureSetup {
+ public FixtureSetup() {
+ TestSetup.setupContext();
+ }
+}
@@ -1,5 +1,6 @@
package cleancoderscom.tests.fixtures;
+import cleancoderscom.Context;
import cleancoderscom.PresentCodecastUseCase;
import cleancoderscom.PresentableCodecast;
import cleancoderscom.User;
@@ -15,7 +16,7 @@
}
public List<Object> query() {
- User loggedInUser = CodecastPresentation.gateKeeper.getLoggedInUser();
+ User loggedInUser = Context.gateKeeper.getLoggedInUser();
PresentCodecastUseCase useCase = new PresentCodecastUseCase();
List<PresentableCodecast> presentableCodecasts = useCase.presentCodecasts(loggedInUser);
List<Object> queryResponse = new ArrayList<Object>();

0 comments on commit 72724e5

Please sign in to comment.