Refine search
public Result getResult(WebTarget target) { try { return new CountResult(parse(target.path(Joiner.on(",").join(indexes)).path(Joiner.on(",").join(types)).path("_count").request().header(CONTENT_TYPE, APPLICATION_JSON).buildGet().invoke(String.class)).get("count").getAsLong()); } catch (WebApplicationException e) { return new FailureResult(e.getResponse().getStatus(), e.getMessage()); } } }
@Override public Result getResult(WebTarget target) { try { return new JsonResult(target.path("_alias").path(alias).request().header("Accept", APPLICATION_JSON).header("content-type", APPLICATION_JSON).buildGet().invoke(byte[].class)); } catch (WebApplicationException e) { return new FailureResult(e.getResponse().getStatus(), e.getMessage()); } } }
@Override public Result getResult(WebTarget target) { try { return new JsonResult(target.path("_nodes").request().header(CONTENT_TYPE, APPLICATION_JSON).buildGet().invoke(byte[].class)); } catch (WebApplicationException e) { return new FailureResult(e.getResponse().getStatus(), e.getMessage()); } } }
@Test public void testTsvDetect() throws Exception { populateInitialData(); File folder1 = new File(getPopulator().getPath().toFile(), "tmp/_dac2/folderTSV"); Files.createDirectories(folder1.toPath()); Files.write(new File(folder1, "file.tsv").toPath(), "a\tf\nc\td".getBytes(Charsets.UTF_8)); String folderFormatUrl = "/source/LocalFS1/file_format/tmp/_dac2/folderTSV/file.tsv"; FileFormatUI defaultFormat = expectSuccess(getBuilder(getAPIv2().path(folderFormatUrl)).buildGet(), FileFormatUI.class); assertEquals(FileType.TEXT, defaultFormat.getFileFormat().getFileType()); assertEquals(false, defaultFormat.getFileFormat().getIsFolder()); assertEquals(folderFormatUrl, defaultFormat.getLinks().get("self")); }
@Test public void testErrors() throws Exception { // test non-existent id expectStatus(Response.Status.NOT_FOUND, getBuilder(getPublicAPI(3).path(CATALOG_PATH).path("bad-id")).buildGet()); // test non-existent internal id expectStatus(Response.Status.NOT_FOUND, getBuilder(getPublicAPI(3).path(CATALOG_PATH).path(CatalogServiceHelper.generateInternalId(Arrays.asList("bad-id")))).buildGet()); // test non-existent path expectStatus(Response.Status.NOT_FOUND, getBuilder(getPublicAPI(3).path(CATALOG_PATH).path("by-path").path("doesnot").path("exist")).buildGet()); }
@Test public void testByPath() throws Exception { Source createdSource = createSource(); // test getting a source by name Source source = expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH).path("by-path").path(createdSource.getName())).buildGet(), new GenericType<Source>() {}); assertEquals(source.getId(), createdSource.getId()); // test getting a folder by path expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH).path("by-path").path(createdSource.getName()).path("json")).buildGet(), new GenericType<Folder>() {}); // test getting a file with a url character in name (?) expectSuccess(getBuilder(getPublicAPI(3).path(CATALOG_PATH).path("by-path").path(createdSource.getName()).path("testfiles").path("file_with_?.json")).buildGet(), new GenericType<File>() {}); newNamespaceService().deleteSource(new NamespaceKey(source.getName()), source.getTag()); }
@Test public void testListSources() throws Exception { ResponseList<SourceResource.SourceDeprecated> sources = expectSuccess(getBuilder(getPublicAPI(3).path(SOURCES_PATH)).buildGet(), new GenericType<ResponseList<SourceResource.SourceDeprecated>>() {}); assertEquals(sources.getData().size(), newSourceService().getSources().size()); }
@Test public void testListSources() throws Exception { ClusterStatsResource.ClusterStats stats = expectSuccess(getBuilder(getPublicAPI(3).path(PATH)).buildGet(), ClusterStatsResource.ClusterStats.class); assertNotNull(stats); assertEquals(stats.getSources().size(), newSourceService().getSources().size()); } }
protected DatasetUI getVersionedDataset(DatasetVersionResourcePath datasetVersionPath) { final Invocation invocation = getBuilder( getAPIv2() .path(getPathJoiner().join(datasetVersionPath.toString(), "preview")) ).buildGet(); return expectSuccess(invocation, InitialPreviewResponse.class).getDataset(); }
@Test public void testEmptySpace() throws Exception { ResourceList resourceList = expectSuccess(getBuilder(getAPIv2().path("resourcetree/space3/expand") .queryParam("showSources", false) .queryParam("showSpaces", false) .queryParam("showDatasets", true)).buildGet(), ResourceList.class); assertEquals(0, resourceList.count(ResourceType.SOURCE)); assertEquals(1, resourceList.count(ResourceType.SPACE)); assertEquals(0, resourceList.count(ResourceType.HOME)); assertEquals(0, resourceList.count(ResourceType.VIRTUAL_DATASET)); assertEquals(0, resourceList.count(ResourceType.FOLDER)); }
@Test public void testResourcesBar1() throws Exception { ResourceList resourceList = expectSuccess(getBuilder(getAPIv2().path("resourcetree/space1.foo1.bar1") .queryParam("showDatasets", true)).buildGet(), ResourceList.class); assertEquals(1, resourceList.count(ResourceType.VIRTUAL_DATASET)); assertEquals(0, resourceList.count(ResourceType.FOLDER)); assertEquals("ds3", resourceList.getResources().get(0).getName()); }
@Test public void testResourcesBar2() throws Exception { ResourceList resourceList = expectSuccess(getBuilder(getAPIv2().path("resourcetree/space2.foo2.bar2") .queryParam("showDatasets", true)).buildGet(), ResourceList.class); assertEquals(1, resourceList.count(ResourceType.VIRTUAL_DATASET)); assertEquals(0, resourceList.count(ResourceType.FOLDER)); assertEquals("ds5", resourceList.getResources().get(0).getName()); }