@Before
public void setup() {
when(listPage.getProperties()).thenAnswer(new Answer<ValueMap>() {
@SuppressWarnings("serial")
public ValueMap answer(InvocationOnMock invocation) throws Throwable {
return new ValueMapDecorator(new HashMap<String, Object>() {
{
put(NameConstants.NN_TEMPLATE, GenericListImpl.TMPL_GENERIC_LIST);
}
});
}
});
when(listPage.getContentResource()).thenReturn(contentResource);
when(contentResource.getChild("list")).thenReturn(listResource);
when(listResource.listChildren()).thenReturn(Arrays.asList(resourceOne, resourceTwo).iterator());
when(resourceOne.adaptTo(ValueMap.class)).thenAnswer(new Answer<ValueMap>() {
@SuppressWarnings("serial")
public ValueMap answer(InvocationOnMock invocation) throws Throwable {
return new ValueMapDecorator(new HashMap<String, Object>() {
{
put(NameConstants.PN_TITLE, "titleone");
put(GenericListImpl.PN_VALUE, "valueone");
}
});
}
});
when(resourceTwo.adaptTo(ValueMap.class)).thenAnswer(new Answer<ValueMap>() {
@SuppressWarnings("serial")
public ValueMap answer(InvocationOnMock invocation) throws Throwable {
return new ValueMapDecorator(new HashMap<String, Object>() {
{
put(NameConstants.PN_TITLE, "titletwo");
put(GenericListImpl.PN_VALUE, "valuetwo");
put(NameConstants.PN_TITLE + "." + "fr", "french_title");
put(NameConstants.PN_TITLE + "." + "fr_ch", "swiss_french_title");