forked from cleancoders/CleanCodeCaseStudy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
171 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
FitNesseRoot/CleanCoders/EpisodeOnePresentCodeCasts/PresentNoCodeCasts/content.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
-!|script| | ||
|given no codecasts | | ||
|given user U | | ||
|with user U logged in | | ||
|and with license for U able to view A| | ||
|then presentation user will be U | | ||
|then the following codecasts will be presented for U | | ||
|there will be no codecasts presented | | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
!define TEST_SYSTEM {slim} | ||
!path out/production/cleancoderscom | ||
!contents | ||
|
||
---- | ||
!define TEST_SYSTEM {slim} | ||
!path out/production/cleancoderscom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package cleancoderscom; | ||
|
||
public class Codecast { | ||
private String title; | ||
private String publicationDate; | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public void setPublicationDate(String publicationDate) { | ||
this.publicationDate = publicationDate; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package cleancoderscom; | ||
|
||
public class Context { | ||
public static Gateway gateway; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package cleancoderscom; | ||
|
||
public class GateKeeper { | ||
private User loggedInUser; | ||
|
||
public void setLoggedInUser(User loggedInUser) { | ||
this.loggedInUser = loggedInUser; | ||
} | ||
|
||
public User getLoggedInUser() { | ||
return loggedInUser; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package cleancoderscom; | ||
|
||
import java.util.List; | ||
|
||
public interface Gateway { | ||
List<Codecast> findAllCodecasts(); | ||
|
||
void delete(Codecast codecast); | ||
|
||
void save(Codecast codecast); | ||
|
||
void save(User user); | ||
|
||
User findUser(String username); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cleancoderscom; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MockGateway implements Gateway { | ||
|
||
private List<Codecast> codecasts; | ||
private List<User> users; | ||
|
||
public MockGateway() { | ||
codecasts = new ArrayList<Codecast>(); | ||
users = new ArrayList<User>(); | ||
} | ||
|
||
public List<Codecast> findAllCodecasts() { | ||
return codecasts; | ||
} | ||
|
||
public void delete(Codecast codecast) { | ||
codecasts.remove(codecast); | ||
} | ||
|
||
public void save(Codecast codecast) { | ||
codecasts.add(codecast); | ||
} | ||
|
||
public void save(User user) { | ||
users.add(user); | ||
} | ||
|
||
public User findUser(String username) { | ||
for (User user : users) { | ||
if (user.getUserName().equals(username)) | ||
return user; | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package cleancoderscom; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class PresentCodecastUseCase { | ||
public List<PresentableCodecast> presentCodecasts(User loggedInUser) { | ||
return new ArrayList<PresentableCodecast>(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package cleancoderscom; | ||
|
||
public class PresentableCodecast { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package cleancoderscom; | ||
|
||
public class User { | ||
private String userName; | ||
|
||
public User(String userName) { | ||
this.userName = userName; | ||
} | ||
|
||
public String getUserName() { | ||
return userName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,51 @@ | ||
package cleancoderscom.fixtures; | ||
|
||
import cleancoderscom.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class CodecastPresentation { | ||
private PresentCodecastUseCase useCase = new PresentCodecastUseCase(); | ||
private GateKeeper gateKeeper = new GateKeeper(); | ||
|
||
public CodecastPresentation() { | ||
Context.gateway = new MockGateway(); | ||
} | ||
|
||
public boolean addUser(String username) { | ||
Context.gateway.save(new User(username)); | ||
return true; | ||
} | ||
|
||
public boolean loginUser(String username) { | ||
return false; | ||
User user = Context.gateway.findUser(username); | ||
if (user != null) { | ||
gateKeeper.setLoggedInUser(user); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
public boolean createLicenseForViewing(String user, String codecast) { | ||
return false; | ||
} | ||
|
||
public String presentationUser() { | ||
return "TILT"; | ||
return gateKeeper.getLoggedInUser().getUserName(); | ||
} | ||
|
||
public boolean clearCodecasts() { | ||
return false; | ||
List<Codecast> codecasts = Context.gateway.findAllCodecasts(); | ||
for (Codecast codecast : new ArrayList<Codecast>(codecasts)) { | ||
Context.gateway.delete(codecast); | ||
} | ||
return Context.gateway.findAllCodecasts().size() == 0; | ||
} | ||
|
||
public int countOfCodecastsPresented() { | ||
return -1; | ||
List<PresentableCodecast> presentations = useCase.presentCodecasts(gateKeeper.getLoggedInUser()); | ||
return presentations.size(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
package cleancoderscom.fixtures; | ||
|
||
import cleancoderscom.Codecast; | ||
import cleancoderscom.Context; | ||
|
||
public class GivenCodecasts { | ||
public void setTitle(String title) { | ||
private String title; | ||
private String publicationDate; | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public void setPublished(String publicationDate) { | ||
this.publicationDate = publicationDate; | ||
} | ||
|
||
public void execute() { | ||
Codecast codecast = new Codecast(); | ||
codecast.setTitle(title); | ||
codecast.setPublicationDate(publicationDate); | ||
Context.gateway.save(codecast); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters