Skip to content

Instantly share code, notes, and snippets.

@justinedelson
Created June 30, 2016 00:36
Show Gist options
  • Save justinedelson/f13a22393cb17fe24193a5efe376b652 to your computer and use it in GitHub Desktop.
Save justinedelson/f13a22393cb17fe24193a5efe376b652 to your computer and use it in GitHub Desktop.
Testing Sightly use pojo
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);
}
}
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