@Test(expected = NoActiveSchemaException.class) public void noSchema() { HiveRoad road = HiveRoad .builder() .name(ROAD_NAME) .schemas(schemas(schemaVersion1Deleted)) .destinations(destinations) .status(status) .build(); underTest.checkAndApply(road); verifyNoMoreInteractions(notificationHandler); }
public List<PatchOperation> checkAndApply(HiveRoad road) { List<PatchOperation> patches = new ArrayList<>(); String name = road.getName(); SchemaVersion latestSchemaVersion = road .getSchemas() .entrySet() .stream() .map(Entry::getValue) .filter(s -> !s.isDeleted()) .max(Ordering.natural().onResultOf(SchemaVersion::getVersion)) .orElseThrow(() -> new NoActiveSchemaException()); Schema schema = latestSchemaVersion.getSchema(); int version = latestSchemaVersion.getVersion(); if (!tableExists.test(name)) { patches.addAll(createTable(name, schema, version)); } else if (schemaVersionChanged.test(name, version)) { patches.addAll(updateSchema(name, schema, version)); } else { log.debug("Nothing to do for road {}", road.getName()); } return patches; }
HiveTableAction { public List<PatchOperation> checkAndApply(HiveRoad road) { List<PatchOperation> patches = new ArrayList<>(); String name = road.getName(); SchemaVersion latestSchemaVersion = road .getSchemas() .entrySet() .stream() .map(Entry::getValue) .filter(s -> !s.isDeleted()) .max(Ordering.natural().onResultOf(SchemaVersion::getVersion)) .orElseThrow(() -> new NoActiveSchemaException()); Schema schema = latestSchemaVersion.getSchema(); int version = latestSchemaVersion.getVersion(); if (!tableExists.test(name)) { patches.addAll(createTable(name, schema, version)); } else if (schemaVersionChanged.test(name, version)) { patches.addAll(updateSchema(name, schema, version)); } else { log.debug("Nothing to do for road {}", road.getName()); } return patches; } }
HiveTableAction { public List<PatchOperation> checkAndApply(HiveRoad road) { List<PatchOperation> patches = new ArrayList<>(); String name = road.getName(); SchemaVersion latestSchemaVersion = road .getSchemas() .entrySet() .stream() .map(Entry::getValue) .filter(s -> !s.isDeleted()) .max(Ordering.natural().onResultOf(SchemaVersion::getVersion)) .orElseThrow(() -> new NoActiveSchemaException()); Schema schema = latestSchemaVersion.getSchema(); int version = latestSchemaVersion.getVersion(); if (!tableExists.test(name)) { patches.addAll(createTable(name, schema, version)); } else if (schemaVersionChanged.test(name, version)) { patches.addAll(updateSchema(name, schema, version)); } else { log.debug("Nothing to do for road {}", road.getName()); } return patches; } @Autowired  HiveTableAction(
      HiveTableManager hiveTableManager,
      LoadingCacheFactory loadingCacheFactory,
      HiveNotificationHandler hiveNotificationHandler,
      @Value("${hive.grantPublicSelect:false}") boolean grantPublicSelect); }
HiveTableAction { public List<PatchOperation> checkAndApply(HiveRoad road) { List<PatchOperation> patches = new ArrayList<>(); String name = road.getName(); SchemaVersion latestSchemaVersion = road .getSchemas() .entrySet() .stream() .map(Entry::getValue) .filter(s -> !s.isDeleted()) .max(Ordering.natural().onResultOf(SchemaVersion::getVersion)) .orElseThrow(() -> new NoActiveSchemaException()); Schema schema = latestSchemaVersion.getSchema(); int version = latestSchemaVersion.getVersion(); if (!tableExists.test(name)) { patches.addAll(createTable(name, schema, version)); } else if (schemaVersionChanged.test(name, version)) { patches.addAll(updateSchema(name, schema, version)); } else { log.debug("Nothing to do for road {}", road.getName()); } return patches; } @Autowired  HiveTableAction(
      HiveTableManager hiveTableManager,
      LoadingCacheFactory loadingCacheFactory,
      HiveNotificationHandler hiveNotificationHandler,
      @Value("${hive.grantPublicSelect:false}") boolean grantPublicSelect); List<PatchOperation> checkAndApply(HiveRoad road); }
HiveTableAction { public List<PatchOperation> checkAndApply(HiveRoad road) { List<PatchOperation> patches = new ArrayList<>(); String name = road.getName(); SchemaVersion latestSchemaVersion = road .getSchemas() .entrySet() .stream() .map(Entry::getValue) .filter(s -> !s.isDeleted()) .max(Ordering.natural().onResultOf(SchemaVersion::getVersion)) .orElseThrow(() -> new NoActiveSchemaException()); Schema schema = latestSchemaVersion.getSchema(); int version = latestSchemaVersion.getVersion(); if (!tableExists.test(name)) { patches.addAll(createTable(name, schema, version)); } else if (schemaVersionChanged.test(name, version)) { patches.addAll(updateSchema(name, schema, version)); } else { log.debug("Nothing to do for road {}", road.getName()); } return patches; } @Autowired  HiveTableAction(
      HiveTableManager hiveTableManager,
      LoadingCacheFactory loadingCacheFactory,
      HiveNotificationHandler hiveNotificationHandler,
      @Value("${hive.grantPublicSelect:false}") boolean grantPublicSelect); List<PatchOperation> checkAndApply(HiveRoad road);  }