use of io.wcm.testing.mock.aem.MockLanguageManager in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class NavigationImplTest method internalSetup.
protected void internalSetup() throws WCMException {
context.load().json(testBase + CoreComponentTestContext.TEST_CONTENT_JSON, "/content");
context.load().json(testBase + "/test-conf.json", "/conf");
context.registerService(LanguageManager.class, new MockLanguageManager());
LiveRelationshipManager relationshipManager = mock(LiveRelationshipManager.class);
when(relationshipManager.getLiveRelationships(any(Resource.class), isNull(), isNull())).then(invocation -> {
Object[] arguments = invocation.getArguments();
Resource resource = (Resource) arguments[0];
if ("/content/navigation-blueprint".equals(resource.getPath())) {
LiveRelationship liveRelationship = mock(LiveRelationship.class);
when(liveRelationship.getTargetPath()).thenReturn("/content/navigation-livecopy");
final ArrayList<LiveRelationship> relationships = new ArrayList<>();
relationships.add(liveRelationship);
final Iterator<LiveRelationship> iterator = relationships.iterator();
return new RangeIterator() {
int index = 0;
@Override
public void skip(long skipNum) {
}
@Override
public long getSize() {
return relationships.size();
}
@Override
public long getPosition() {
return index;
}
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public Object next() {
index++;
return iterator.next();
}
};
}
return null;
});
context.registerService(LiveRelationshipManager.class, relationshipManager);
}
Aggregations