Created
June 30, 2016 00:36
-
-
Save justinedelson/f13a22393cb17fe24193a5efe376b652 to your computer and use it in GitHub Desktop.
Testing Sightly use pojo
This file contains hidden or 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
import com.adobe.cq.sightly.WCMUsePojo; | |
public class SampleUse extends WCMUsePojo { | |
@Override | |
public void activate() throws Exception { | |
} | |
public String getName() { | |
return get("name", String.class); | |
} | |
} |
This file contains hidden or 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
import org.junit.Test; | |
import javax.script.Bindings; | |
import static org.mockito.Mockito.*; | |
import static org.junit.Assert.*; | |
public class SampleUseTest { | |
@Test | |
public void test() { | |
Bindings bindings = mock(Bindings.class); | |
when(bindings.get("name")).thenReturn("hello"); | |
SampleUse use = new SampleUse(); | |
use.init(bindings); | |
assertEquals("hello", use.getName()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment