Package com.linkedin.restli.tools.compatibility

Examples of com.linkedin.restli.tools.compatibility.CompatibilityInfoMap


{
  @Test
  public void testCompatibleRestSpecVsSnapshot()
  {
    final RestLiSnapshotCompatibilityChecker checker = new RestLiSnapshotCompatibilityChecker();
    final CompatibilityInfoMap infoMap = checker.checkRestSpecVsSnapshot(RESOURCES_DIR + FS + "idls" + FS + "twitter-statuses.restspec.json",
                                                                         RESOURCES_DIR + FS + "snapshots" + FS + "twitter-statuses.snapshot.json",
                                                                         CompatibilityLevel.EQUIVALENT);
    Assert.assertTrue(infoMap.isEquivalent());
  }
View Full Code Here


                                            CompatibilityInfo.Type.SUPERSET, new HashSet<String>(Arrays.asList("create"))));
    restSpecDiffs.add(new CompatibilityInfo(Arrays.<Object>asList("", "collection", "methods"),
                                            CompatibilityInfo.Type.SUPERSET, new HashSet<String>(Arrays.asList("create"))));

    final RestLiSnapshotCompatibilityChecker checker = new RestLiSnapshotCompatibilityChecker();
    final CompatibilityInfoMap incompatibleInfoMap = checker.checkRestSpecVsSnapshot(RESOURCES_DIR + FS + "idls" + FS + "twitter-statuses-incompatible.restspec.json",
                                                                                     RESOURCES_DIR + FS + "snapshots" + FS + "twitter-statuses.snapshot.json",
                                                                                     CompatibilityLevel.EQUIVALENT);
    Assert.assertTrue(incompatibleInfoMap.isModelEquivalent());

    final Collection<CompatibilityInfo> restSpecIncompatibles = incompatibleInfoMap.getRestSpecIncompatibles();
    final Collection<CompatibilityInfo> restSpecCompatibles = incompatibleInfoMap.getRestSpecCompatibles();

    for (CompatibilityInfo te : restSpecErrors)
    {
      Assert.assertTrue(restSpecIncompatibles.contains(te), "Reported restspec incompatibles should contain: " + te.toString());
      restSpecIncompatibles.remove(te);
View Full Code Here

                                              CompatibilityInfo.Type.RESOURCE_NEW,
                                              nonExistentFilename2));

    final RestLiSnapshotCompatibilityChecker checker = new RestLiSnapshotCompatibilityChecker();

    CompatibilityInfoMap infoMap = checker.check(nonExistentFilename1,
                                               nonExistentFilename2,
                                               CompatibilityLevel.BACKWARDS);
    Assert.assertFalse(infoMap.isCompatible(CompatibilityLevel.BACKWARDS));

    final Collection<CompatibilityInfo> incompatibles = new HashSet<CompatibilityInfo>(infoMap.getIncompatibles());
    final Collection<CompatibilityInfo> compatibles = new HashSet<CompatibilityInfo>(infoMap.getCompatibles());

    for (CompatibilityInfo te : incompatibles)
    {
      Assert.assertTrue(testIncompatibles.contains(te), "Reported incompatibles should contain: " + te.toString());
      incompatibles.remove(te);
View Full Code Here

    for (int i = 1; i < targets.length; i += 2)
    {
      String prevTarget = targets[i - 1];
      String currTarget = targets[i];
      CompatibilityInfoMap infoMap = checker.check(prevTarget, currTarget, compat);
      result &= infoMap.isCompatible(compat);
      allSummaries.append(infoMap.createSummary(prevTarget, currTarget));

    }

    if (compat != CompatibilityLevel.OFF && allSummaries.length() > 0)
    {
View Full Code Here

    return checkCompatibility(prevRestSpecPath, currSnapshotPath, compatLevel, true);
  }

  private CompatibilityInfoMap checkCompatibility(String prevRestModelPath, String currRestModelPath, CompatibilityLevel compatLevel, boolean isAgainstRestSpec)
  {
    final CompatibilityInfoMap infoMap = new CompatibilityInfoMap();
    if (compatLevel == CompatibilityLevel.OFF)
    {
      // skip check entirely.
      return infoMap;
    }

    final Stack<Object> path = new Stack<Object>();
    path.push("");

    FileInputStream prevSnapshotFile = null;
    FileInputStream currSnapshotFile = null;

    try
    {
      prevSnapshotFile = new FileInputStream(prevRestModelPath);
    }
    catch (FileNotFoundException e)
    {
      infoMap.addRestSpecInfo(CompatibilityInfo.Type.RESOURCE_NEW, path, currRestModelPath);
    }

    try
    {
      currSnapshotFile = new FileInputStream(currRestModelPath);
    }
    catch (FileNotFoundException e)
    {
      infoMap.addRestSpecInfo(CompatibilityInfo.Type.RESOURCE_MISSING, path, prevRestModelPath);
    }

    if (prevSnapshotFile == null || currSnapshotFile == null)
    {
      return infoMap;
    }

    AbstractSnapshot prevSnapshot = null;
    AbstractSnapshot currSnapshot = null;
    try
    {
      if (isAgainstRestSpec)
      {
        prevSnapshot = new RestSpec(prevSnapshotFile);
      }
      else
      {
        prevSnapshot = new Snapshot(prevSnapshotFile);
      }

      currSnapshot = new Snapshot(currSnapshotFile);
    }
    catch (IOException e)
    {
      infoMap.addRestSpecInfo(CompatibilityInfo.Type.OTHER_ERROR, path, e.getMessage());
    }

    if (prevSnapshot == null || currSnapshot == null)
    {
      return infoMap;
    }

    final DataSchemaResolver currResolver = createResolverFromSnapshot(currSnapshot, _resolverPath);
    final DataSchemaResolver prevResolver;
    if (isAgainstRestSpec)
    {
      prevResolver = currResolver;
    }
    else
    {
      prevResolver = createResolverFromSnapshot(prevSnapshot, _resolverPath);
    }

    final ResourceCompatibilityChecker checker = new ResourceCompatibilityChecker(prevSnapshot.getResourceSchema(), prevResolver,
                                                                                  currSnapshot.getResourceSchema(), currResolver);
    checker.check(compatLevel);
    infoMap.addAll(checker.getInfoMap());

    return infoMap;
  }
View Full Code Here

TOP

Related Classes of com.linkedin.restli.tools.compatibility.CompatibilityInfoMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.