use of com.eden.orchid.api.indexing.OrchidRootIndex in project Orchid by JavaEden.
the class GeneratorServiceTest method setUp.
@BeforeEach
public void setUp() {
context = mock(OrchidContext.class);
extractor = mock(OptionsExtractor.class);
theme = mock(Theme.class);
buildMetrics = new BuildMetrics(context);
internalIndex = new OrchidRootIndex(context, "internal");
when(context.resolve(OptionsExtractor.class)).thenReturn(extractor);
when(context.findTheme(any())).thenReturn(theme);
when(context.getIndex()).thenReturn(internalIndex);
when(context.includeDrafts()).thenReturn(false);
when(context.getEmbeddedData(anyString(), anyString())).thenReturn(new EdenPair<>("", new HashMap<>()));
generators = new HashSet<>();
mockPage1Reference = new OrchidReference(context, "page1.html");
mockPage1Resource = new StringResource(mockPage1Reference, "");
mockPage1 = spy(new OrchidPage(mockPage1Resource, RenderService.RenderMode.TEMPLATE, "mockPage1", ""));
pages1 = new ArrayList<>();
pages1.add(mockPage1);
generator1 = spy(new MockGenerator("gen1", OrchidGenerator.Stage.COLLECTION, pages1));
generators.add(generator1);
mockPage2Reference = new OrchidReference(context, "page2.html");
mockFreeableResource = spy(new OrchidResource(mockPage2Reference) {
@Nonnull
@Override
public InputStream getContentStream() {
return OrchidExtensionsKt.asInputStream("");
}
});
mockPage2 = spy(new OrchidPage(mockFreeableResource, RenderService.RenderMode.TEMPLATE, "mockPage2", ""));
pages2 = new ArrayList<>();
pages2.add(mockPage2);
generator2 = spy(new MockGenerator("gen2", OrchidGenerator.Stage.CONTENT, pages2));
generators.add(generator2);
pages3 = new ArrayList<>();
generator3 = new MockGenerator("gen3", OrchidGenerator.Stage.WARM_UP, pages3);
generator3 = spy(generator3);
generators.add(generator3);
when(context.resolveSet(OrchidGenerator.class)).thenReturn(generators);
// test the service directly
service = new GeneratorServiceImpl();
service.initialize(context);
// test that the default implementation is identical to the real implementation
underTest = new GeneratorService() {
public void initialize(OrchidContext context) {
}
public <T extends OrchidService> T getService(Class<T> serviceClass) {
return (T) service;
}
};
}
Aggregations