- public SchemaContext getSchemaContext() {
- return this.schemaContext;
- }
-
- public SchemaService createMockSchemaService(SchemaContext mockContext) {
- if (mockContext == null) {
- mockContext = createMockSchemaContext();
- }
-
- final SchemaService mockSchemaService = mock(SchemaService.class);
- when(mockSchemaService.getGlobalContext()).thenReturn(mockContext);
- return mockSchemaService;
- }
-
- public SchemaContext createMockSchemaContext() {
- final SchemaContext mockContext = mock(SchemaContext.class);
- when(mockContext.getModules()).thenReturn(this.modules);
-
- final ArgumentCaptor<String> moduleCapture = ArgumentCaptor.forClass(String.class);
- final ArgumentCaptor<Optional> dateCapture = ArgumentCaptor.forClass(Optional.class);
- final ArgumentCaptor<URI> namespaceCapture = ArgumentCaptor.forClass(URI.class);
- when(mockContext.findModule(moduleCapture.capture(), dateCapture.capture())).then(
- invocation -> {
- final String module = moduleCapture.getValue();
- final Optional<?> date = dateCapture.getValue();
- for (final Module m : Collections.unmodifiableSet(DocGenTestHelper.this.modules)) {
- if (m.getName().equals(module) && m.getRevision().equals(date)) {
- return Optional.of(m);
- }
- }
- return Optional.empty();
- });
- when(mockContext.findModule(namespaceCapture.capture(), dateCapture.capture())).then(
- invocation -> {
- final URI namespace = namespaceCapture.getValue();
- final Optional<?> date = dateCapture.getValue();
- for (final Module m : Collections.unmodifiableSet(DocGenTestHelper.this.modules)) {
- if (m.getNamespace().equals(namespace) && m.getRevision().equals(date)) {
- return Optional.of(m);
- }
- }
- return Optional.empty();
- });
- return mockContext;
- }
-
- public UriInfo createMockUriInfo(final String urlPrefix) throws URISyntaxException {