use of com.reprezen.swagedit.editor.hyperlinks.SwaggerReferenceHyperlinkDetector in project KaiZen-OpenAPI-Editor by RepreZen.
the class Mocks method mockHyperlinkDetector.
public static JsonReferenceHyperlinkDetector mockHyperlinkDetector(final URI uri, final JsonNode document) {
final JsonDocumentManager manager = mock(JsonDocumentManager.class);
final IFile file = mock(IFile.class);
when(file.exists()).thenReturn(true);
when(manager.getDocument(Mockito.any(URI.class))).thenReturn(document);
when(manager.getFile(Mockito.any(URI.class))).thenReturn(file);
return new SwaggerReferenceHyperlinkDetector() {
// allow running tests as non plugin tests
protected URI getBaseURI() {
return uri;
}
protected JsonReferenceFactory getFactory() {
return new JsonReferenceFactory() {
@Override
public JsonReference createSimpleReference(URI baseURI, AbstractNode valueNode) {
JsonReference ref = super.createSimpleReference(baseURI, valueNode);
if (ref != null) {
ref.setDocumentManager(manager);
}
return ref;
}
@Override
public JsonReference create(AbstractNode node) {
JsonReference ref = super.create(node);
ref.setDocumentManager(manager);
return ref;
}
@Override
public JsonReference create(JsonNode node) {
JsonReference ref = super.create(node);
ref.setDocumentManager(manager);
return ref;
}
;
};
}
};
}
Aggregations