gpt4 book ai didi

org.apache.atlas.repository.impexp.ZipSource类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 13:07:44 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.atlas.repository.impexp.ZipSource类的一些代码示例,展示了ZipSource类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipSource类的具体详情如下:
包路径:org.apache.atlas.repository.impexp.ZipSource
类名称:ZipSource

ZipSource介绍

暂无

代码示例

代码示例来源:origin: org.apache.atlas/atlas-repository

@Test
public void improperInit_ReturnsNullCreationOrder() throws IOException, AtlasBaseException {
  byte bytes[] = new byte[10];
  ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
  ZipSource zs = new ZipSource(bais);
  List<String> s = zs.getCreationOrder();
  Assert.assertNull(s);
}

代码示例来源:origin: org.apache.atlas/atlas-repository

@Override
public AtlasEntityWithExtInfo getNextEntityWithExtInfo() {
  try {
    currentPosition++;
    return getEntityWithExtInfo(this.iterator.next());
  } catch (AtlasBaseException e) {
    LOG.error("getNextEntityWithExtInfo", e);
    return null;
  }
}

代码示例来源:origin: org.apache.atlas/atlas-repository

@Override
public AtlasEntity next() {
  AtlasEntityWithExtInfo entityWithExtInfo = getNextEntityWithExtInfo();
  return entityWithExtInfo != null ? entityWithExtInfo.getEntity() : null;
}

代码示例来源:origin: apache/incubator-atlas

private void setStartPosition(AtlasImportRequest request, ZipSource source) throws AtlasBaseException {
  if(request.getStartGuid() != null) {
    source.setPositionUsingEntityGuid(request.getStartGuid());
  } else if(request.getStartPosition() != null) {
    source.setPosition(Integer.parseInt(request.getStartPosition()));
  }
}

代码示例来源:origin: org.apache.atlas/atlas-repository

public AtlasEntity.AtlasEntityWithExtInfo getEntityWithExtInfo(String guid) throws AtlasBaseException {
  String s = getFromCache(guid);
  AtlasEntity.AtlasEntityWithExtInfo entityWithExtInfo = convertFromJson(AtlasEntity.AtlasEntityWithExtInfo.class, s);
  if (importTransform != null) {
    entityWithExtInfo = importTransform.apply(entityWithExtInfo);
  }
  return entityWithExtInfo;
}

代码示例来源:origin: org.apache.atlas/atlas-repository

@Test(dataProvider = "zipFileStocks")
public void iteratorBehavor_WorksAsExpected(ZipSource zipSource) throws IOException, AtlasBaseException {
  Assert.assertTrue(zipSource.hasNext());
  List<String> creationOrder = zipSource.getCreationOrder();
  for (int i = 0; i < creationOrder.size(); i++) {
    AtlasEntity e = zipSource.next();
    assertNotNull(e);
    assertEquals(e.getGuid(), creationOrder.get(i));
  }
  assertFalse(zipSource.hasNext());
}

代码示例来源:origin: org.apache.atlas/atlas-repository

@Test(dataProvider = "sales")
public void iteratorSetPositionBehavor(ZipSource zipSource) throws IOException, AtlasBaseException {
  Assert.assertTrue(zipSource.hasNext());
  List<String> creationOrder = zipSource.getCreationOrder();
  int moveToPosition_2 = 2;
  zipSource.setPosition(moveToPosition_2);
  assertEquals(zipSource.getPosition(), moveToPosition_2);
  assertTrue(zipSource.getPosition() < creationOrder.size());
  assertTrue(zipSource.hasNext());
  for (int i = 1; i < 4; i++) {
    zipSource.next();
    assertEquals(zipSource.getPosition(), moveToPosition_2 + i);
  }
  assertTrue(zipSource.hasNext());
}

代码示例来源:origin: org.apache.atlas/atlas-repository

@DataProvider(name = "zipFileStocksFloat")
public static Object[][] getDataFromZipFileWithLongFloats() throws IOException {
  FileInputStream fs = ZipFileResourceTestUtils.getFileInputStream("stocks-float.zip");
  return new Object[][] {{ new ZipSource(fs) }};
}

代码示例来源:origin: org.apache.atlas/atlas-repository

@Test(dataProvider = "zipFileStocks")
public void applyTransformation(ZipSource zipSource) throws IOException, AtlasBaseException {
  ImportTransforms transforms = getTransformForHiveDB();
  zipSource.setImportTransform(transforms);
  Assert.assertTrue(zipSource.hasNext());
  List<String> creationOrder = zipSource.getCreationOrder();
  for (int i = 0; i < creationOrder.size(); i++) {
    AtlasEntity e = zipSource.next();
    if(e.getTypeName().equals("hive_db")) {
      Object o = e.getAttribute("qualifiedName");
      String s = (String) o;
      assertNotNull(e);
      assertTrue(s.contains("@cl2"));
      break;
    }
  }
}

代码示例来源:origin: org.apache.atlas/atlas-repository

@Test
public void requestingEntityNotFound_NoData() throws AtlasBaseException, IOException {
  String requestingIP = "1.0.0.0";
  String hostName = "root";
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  ZipSink zipSink = new ZipSink(baos);
  AtlasExportResult result = exportService.run(
      zipSink, getRequestForFullFetch(), "admin", hostName, requestingIP);
  Assert.assertNull(result.getData());
  ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
  ZipSource zipSource = new ZipSource(bais);
  assertNotNull(exportService);
  assertNotNull(zipSource.getCreationOrder());
  Assert.assertFalse(zipSource.hasNext());
}

代码示例来源:origin: apache/incubator-atlas

processTypes(source.getTypesDef(), result);
setStartPosition(request, source);
processEntities(source, result);
source.close();
LOG.info("<== import(user={}, from={}): status={}", userName, requestingIP, result.getOperationStatus());
ZipSource source = new ZipSource(new ByteArrayInputStream(FileUtils.readFileToByteArray(file)), ImportTransforms.fromJson(transforms));

代码示例来源:origin: org.apache.atlas/atlas-repository

public AtlasImportResult run(ZipSource source, AtlasImportRequest request, String userName,
               String hostName, String requestingIP) throws AtlasBaseException {
  if (request == null) {
    request = new AtlasImportRequest();
  }
  AtlasImportResult result = new AtlasImportResult(request, userName, requestingIP, hostName, System.currentTimeMillis());
  try {
    LOG.info("==> import(user={}, from={})", userName, requestingIP);
    String transforms = MapUtils.isNotEmpty(request.getOptions()) ? request.getOptions().get(AtlasImportRequest.TRANSFORMS_KEY) : null;
    source.setImportTransform(ImportTransforms.fromJson(transforms));
    startTimestamp = System.currentTimeMillis();
    processTypes(source.getTypesDef(), result);
    setStartPosition(request, source);
    processEntities(source, result);
    result.setOperationStatus(AtlasImportResult.OperationStatus.SUCCESS);
  } catch (AtlasBaseException excp) {
    LOG.error("import(user={}, from={}): failed", userName, requestingIP, excp);
    throw excp;
  } catch (Exception excp) {
    LOG.error("import(user={}, from={}): failed", userName, requestingIP, excp);
    throw new AtlasBaseException(excp);
  } finally {
    source.close();
    LOG.info("<== import(user={}, from={}): status={}", userName, requestingIP, result.getOperationStatus());
  }
  return result;
}

代码示例来源:origin: org.apache.atlas/atlas-repository

@Test(dataProvider = "zipFileStocks")
public void examineContents_BehavesAsExpected(ZipSource zipSource) throws IOException, AtlasBaseException {
  List<String> creationOrder = zipSource.getCreationOrder();
  assertNotNull(creationOrder);
  assertEquals(creationOrder.size(), 4);
  AtlasTypesDef typesDef = zipSource.getTypesDef();
  assertNotNull(typesDef);
  assertEquals(typesDef.getEntityDefs().size(), 6);
  useCreationOrderToFetchEntitiesWithExtInfo(zipSource, creationOrder);
  useCreationOrderToFetchEntities(zipSource, creationOrder);
  attemptToFetchNonExistentGuid_ReturnsNull(zipSource, "non-existent-guid");
  verifyGuidRemovalOnImportComplete(zipSource, creationOrder.get(0));
}

代码示例来源:origin: org.apache.atlas/atlas-repository

@Test(dataProvider = "zipFileStocksFloat")
public void attemptToSerializeLongFloats(ZipSource zipSource) throws IOException, AtlasBaseException {
  Assert.assertTrue(zipSource.hasNext());
  assertTrue(zipSource.hasNext());
  assertTrue(zipSource.hasNext());
  AtlasEntity.AtlasEntityWithExtInfo e = zipSource.getNextEntityWithExtInfo();
  assertNotNull(e);
  assertTrue(e.getEntity().getClassifications().size() > 0);
  assertNotNull(e.getEntity().getClassifications().get(0).getAttribute("fv"));
  assertEquals(e.getEntity().getClassifications().get(0).getAttribute("fv").toString(), "3.4028235E+38");
  assertTrue(zipSource.hasNext());
}

代码示例来源:origin: org.apache.atlas/atlas-repository

@Test
public void requestingExportOfNonExistentEntity_ReturnsFailure() throws Exception {
  AtlasExportRequest request = getRequestForEmployee();
  tamperEmployeeRequest(request);
  ZipSource zipSource = runExportWithParameters(request);
  assertNotNull(zipSource.getCreationOrder());
  assertEquals(zipSource.getCreationOrder().size(), 0);
  assertEquals(AtlasExportResult.OperationStatus.FAIL, zipSource.getExportResult().getOperationStatus());
}

代码示例来源:origin: apache/incubator-atlas

@Override
public void reset() {
  try {
    getCreationOrder();
    this.iterator = this.creationOrder.iterator();
  } catch (AtlasBaseException e) {
    LOG.error("reset", e);
  }
}

代码示例来源:origin: apache/incubator-atlas

@Override
public void setPositionUsingEntityGuid(String guid) {
  if(StringUtils.isBlank(guid)) {
    return;
  }
  int index = creationOrder.indexOf(guid);
  if (index == -1) {
    return;
  }
  setPosition(index);
}

代码示例来源:origin: org.apache.atlas/atlas-repository

private void verifyTypeDefs(ZipSource zipSource) throws AtlasBaseException {
    assertEquals(zipSource.getTypesDef().getEnumDefs().size(), 1);
    assertEquals(zipSource.getTypesDef().getClassificationDefs().size(), 0);
    assertEquals(zipSource.getTypesDef().getStructDefs().size(), 1);
    assertEquals(zipSource.getTypesDef().getEntityDefs().size(), 4);
  }
}

代码示例来源:origin: apache/incubator-atlas

@Test(dataProvider = "zipFileStocks")
public void iteratorBehavor_WorksAsExpected(ZipSource zipSource) throws IOException, AtlasBaseException {
  Assert.assertTrue(zipSource.hasNext());
  List<String> creationOrder = zipSource.getCreationOrder();
  for (int i = 0; i < creationOrder.size(); i++) {
    AtlasEntity e = zipSource.next();
    assertNotNull(e);
    assertEquals(e.getGuid(), creationOrder.get(i));
  }
  assertFalse(zipSource.hasNext());
}

代码示例来源:origin: apache/incubator-atlas

@Test(dataProvider = "sales")
public void iteratorSetPositionBehavor(ZipSource zipSource) throws IOException, AtlasBaseException {
  Assert.assertTrue(zipSource.hasNext());
  List<String> creationOrder = zipSource.getCreationOrder();
  int moveToPosition_2 = 2;
  zipSource.setPosition(moveToPosition_2);
  assertEquals(zipSource.getPosition(), moveToPosition_2);
  assertTrue(zipSource.getPosition() < creationOrder.size());
  assertTrue(zipSource.hasNext());
  for (int i = 1; i < 4; i++) {
    zipSource.next();
    assertEquals(zipSource.getPosition(), moveToPosition_2 + i);
  }
  assertTrue(zipSource.hasNext());
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com