Search in sources :

Example 6 with JsonReference

use of com.reprezen.swagedit.core.json.references.JsonReference in project KaiZen-OpenAPI-Editor by RepreZen.

the class JsonReferenceFactoryTest method test6.

@Test
public void test6() throws URISyntaxException {
    JsonReferenceFactory factory = new JsonReferenceFactory();
    JsonReference result = factory.doCreate("file://path/to/file/doc.yaml", null);
    assertEquals(URI.create("file://path/to/file/doc.yaml"), result.getUri());
    assertFalse(result.isLocal());
    assertTrue(result.isAbsolute());
    assertEquals(JsonPointer.compile(""), result.getPointer());
}
Also used : JsonReference(com.reprezen.swagedit.core.json.references.JsonReference) JsonReferenceFactory(com.reprezen.swagedit.core.json.references.JsonReferenceFactory) Test(org.junit.Test)

Example 7 with JsonReference

use of com.reprezen.swagedit.core.json.references.JsonReference in project KaiZen-OpenAPI-Editor by RepreZen.

the class Mocks method mockJsonReferenceFactory.

public static JsonReferenceFactory mockJsonReferenceFactory(final Map<URI, JsonNode> entries) {
    final IFile file = mock(IFile.class);
    when(file.exists()).thenReturn(true);
    return new JsonReferenceFactory() {

        public JsonReference create(AbstractNode node) {
            JsonReference ref = super.create(node);
            ref.setDocumentManager(new JsonDocumentManager() {

                @Override
                public IFile getFile(URI uri) {
                    return file;
                }

                @Override
                public JsonNode getDocument(URI uri) {
                    return entries.get(uri);
                }
            });
            return ref;
        }

        ;
    };
}
Also used : JsonReference(com.reprezen.swagedit.core.json.references.JsonReference) IFile(org.eclipse.core.resources.IFile) AbstractNode(com.reprezen.swagedit.core.model.AbstractNode) JsonReferenceFactory(com.reprezen.swagedit.core.json.references.JsonReferenceFactory) JsonNode(com.fasterxml.jackson.databind.JsonNode) JsonDocumentManager(com.reprezen.swagedit.core.json.references.JsonDocumentManager) URI(java.net.URI)

Example 8 with JsonReference

use of com.reprezen.swagedit.core.json.references.JsonReference in project KaiZen-OpenAPI-Editor by RepreZen.

the class JsonReferenceFactoryTest method test2.

@Test
public void test2() throws URISyntaxException {
    JsonReferenceFactory factory = new JsonReferenceFactory();
    JsonReference result = factory.doCreate("doc.yaml#/definitions/Foo", null);
    assertEquals(new URI(null, "doc.yaml", "/definitions/Foo"), result.getUri());
    assertFalse(result.isLocal());
    assertFalse(result.isAbsolute());
    assertEquals(JsonPointer.compile("/definitions/Foo"), result.getPointer());
}
Also used : JsonReference(com.reprezen.swagedit.core.json.references.JsonReference) JsonReferenceFactory(com.reprezen.swagedit.core.json.references.JsonReferenceFactory) URI(java.net.URI) Test(org.junit.Test)

Example 9 with JsonReference

use of com.reprezen.swagedit.core.json.references.JsonReference in project KaiZen-OpenAPI-Editor by RepreZen.

the class JsonReferenceFactoryTest method test.

@Test
public void test() throws URISyntaxException {
    JsonReferenceFactory factory = new JsonReferenceFactory();
    JsonReference result = factory.doCreate("#/definitions/Foo", null);
    assertEquals(new URI(null, null, "/definitions/Foo"), result.getUri());
    assertTrue(result.isLocal());
    assertFalse(result.isAbsolute());
    assertEquals(JsonPointer.compile("/definitions/Foo"), result.getPointer());
}
Also used : JsonReference(com.reprezen.swagedit.core.json.references.JsonReference) JsonReferenceFactory(com.reprezen.swagedit.core.json.references.JsonReferenceFactory) URI(java.net.URI) Test(org.junit.Test)

Aggregations

JsonReference (com.reprezen.swagedit.core.json.references.JsonReference)9 JsonReferenceFactory (com.reprezen.swagedit.core.json.references.JsonReferenceFactory)8 URI (java.net.URI)6 Test (org.junit.Test)6 AbstractNode (com.reprezen.swagedit.core.model.AbstractNode)3 IFile (org.eclipse.core.resources.IFile)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 JsonDocumentManager (com.reprezen.swagedit.core.json.references.JsonDocumentManager)2 SwaggerReferenceHyperlinkDetector (com.reprezen.swagedit.editor.hyperlinks.SwaggerReferenceHyperlinkDetector)1 IRegion (org.eclipse.jface.text.IRegion)1 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)1