Last active
December 18, 2015 00:19
-
-
Save HeartSaVioR/5695842 to your computer and use it in GitHub Desktop.
Podam 의 아주 단순한 "생성" 기능을 담은 Snippet 입니다.
더 상세한 설정은 http://home.btconnect.com/jemosAgile//projects/podam/ 를 참고하세요.
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
package test; | |
public class Model { | |
private String hello; | |
private String world; | |
public Model() { | |
} | |
public String getHello() { | |
return hello; | |
} | |
public void setHello(String hello) { | |
System.out.println("setter called"); | |
this.hello = hello; | |
} | |
public String getWorld() { | |
return world; | |
} | |
} |
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
package test; | |
import static org.junit.Assert.assertNotNull; | |
import static org.junit.Assert.assertNull; | |
import org.junit.Test; | |
import uk.co.jemos.podam.api.PodamFactory; | |
import uk.co.jemos.podam.api.PodamFactoryImpl; | |
public class TestPodam { | |
@Test | |
public void testBasic() { | |
PodamFactory podamFactory = new PodamFactoryImpl(); | |
// 1. 대상 클래스는 public class 여야 한다 (PodamFactory 가 접근할 수 있어야 함) | |
// 2. 대상 클래스는 기본 생성자를 제공해야 한다 | |
// 3. 대상 클래스가 Generic 을 사용하는 경우 PodamFactory.manufacturePojo() 의 두번째 파라미터부터 차례로 입력한다 | |
// 4. 필드의 값은 setter 메소드를 통해 주입된다 | |
// -> setter 메소드가 없는 field 는 값이 주입되지 않는다 | |
Model model = podamFactory.manufacturePojo(Model.class); | |
assertNotNull(model == null); | |
assertNotNull(model.getHello()); | |
assertNull(model.getWorld()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment