Skip to content

Instantly share code, notes, and snippets.

View babjo's full-sized avatar
🎯
Focusing

Chanhyeong Lee babjo

🎯
Focusing
View GitHub Profile
@babjo
babjo / install_openjdk11.sh
Created October 6, 2018 06:02
A script to install openjdk11 with curl
curl https://download.java.net/java/ga/jdk11/openjdk-11_osx-x64_bin.tar.gz \
| tar -xz \
&& sudo mv jdk-11.jdk /Library/Java/JavaVirtualMachines
// global
var myApp = myApp || {};
// namespaces
myApp.routers = myApp.routers || {};
myApp.model = myApp.model || {};
myApp.model.special = myApp.model.special || {};
var testModule = (function () {
var myPrivateVar, myPrivateMethod;
// A private variable
myPrivateVar = 0;
// A private function
myPrivateMethod = function(foo) {
console.log(foo);
};
return {
// A public variable
class AuthClientImpl implements AuthClient {
public long verifyToken(String token) {
String rawJson = decrpyt(token);
User user = deserialize(rawJson);
return user.getId();
}
private String decrpyt(String token) { ... }
private User deserialize(String rawJson) { ... }
}
public class BlogServiceTest {
@Test
public void addPost() {
// given
AuthClient authClient = ...
BlogRepository blogRepository = ...
BlogService service = new BlogService(authClient, blogRepository); // 생성자로 협력 객체 주입
AddPostRequest request = ...
class FakeBlogRepository implements BlogRepository {
private Map<String, List<Post>> data = new HashMap<>();
private long lastPostId = 0L;
public long save(long userId, Post post) {
lastPostId++;
post.setId(lastPostId);
List<Post> posts = data.get(userId);
public class BlogService {
public BlogService(AuthClient authClient, BlogRepository repository) {
this.authClient = authClient;
this.repository = repository;
}
public AddPostResponse addPost(AddPostRequest request) {
// verifyToken 메소드 파라미터 추가
// 리턴 값이 User 객체로 변경
public class BlogServiceTest {
@Mock
private AuthClient authClient; // mock 객체생성
@Mock
private BlogRepository blogRepository; // mock 객체생성
@Test
public void addPost() {
public class Handler {
...
public void handle(Command command) {
command.execute();
}
}
interface Command {
public void execute();
}
public class SendEmailCommand implements Command {
public class SmallClass1 {
private Collaborator collaborator1;
public void doSomething(){
...
}
}
public class SmallClass2 {
private Collaborator collaborator2;
public void doSomething(){
...