@Test(dependsOnMethods = "testSubmit")
  public void testGetDefinition() throws Exception {
    for (HierarchicalTypeDefinition typeDefinition : typeDefinitions) {
      System.out.println("typeName = " + typeDefinition.typeName);

      WebResource resource = service.path("api/atlas/types").path(typeDefinition.typeName);

      ClientResponse clientResponse =
          resource
              .accept(Servlets.JSON_MEDIA_TYPE)
              .type(Servlets.JSON_MEDIA_TYPE)
              .method(HttpMethod.GET, ClientResponse.class);
      assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());

      String responseAsString = clientResponse.getEntity(String.class);
      Assert.assertNotNull(responseAsString);
      JSONObject response = new JSONObject(responseAsString);
      Assert.assertNotNull(response.get(AtlasClient.DEFINITION));
      Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));

      String typesJson = response.getString(AtlasClient.DEFINITION);
      final TypesDef typesDef = TypesSerialization.fromJson(typesJson);
      List<HierarchicalTypeDefinition<ClassType>> hierarchicalTypeDefinitions =
          typesDef.classTypesAsJavaList();
      for (HierarchicalTypeDefinition<ClassType> classType : hierarchicalTypeDefinitions) {
        for (AttributeDefinition attrDef : classType.attributeDefinitions) {
          if ("name".equals(attrDef.name)) {
            assertEquals(attrDef.isIndexable, true);
            assertEquals(attrDef.isUnique, true);
          }
        }
      }
    }
  }
 private void verifyRestoredClassType(TypesDef types, String typeName) throws AtlasException {
   boolean clsTypeFound = false;
   List<HierarchicalTypeDefinition<ClassType>> classTypes = types.classTypesAsJavaList();
   for (HierarchicalTypeDefinition<ClassType> classType : classTypes) {
     if (classType.typeName.equals(typeName)) {
       ClassType expectedType = ts.getDataType(ClassType.class, classType.typeName);
       Assert.assertEquals(
           expectedType.immediateAttrs.size(), classType.attributeDefinitions.length);
       Assert.assertEquals(expectedType.superTypes.size(), classType.superTypes.size());
       Assert.assertEquals(classType.typeDescription, classType.typeName + DESCRIPTION);
       clsTypeFound = true;
     }
   }
   Assert.assertTrue(clsTypeFound, typeName + " type not restored");
 }
  @Test(dependsOnMethods = "testStore")
  public void testRestore() throws Exception {
    TypesDef types = typeStore.restore();

    // validate enum
    List<EnumTypeDefinition> enumTypes = types.enumTypesAsJavaList();
    Assert.assertEquals(1, enumTypes.size());
    EnumTypeDefinition orgLevel = enumTypes.get(0);
    Assert.assertEquals(orgLevel.name, "OrgLevel");
    Assert.assertEquals(orgLevel.description, "OrgLevel" + DESCRIPTION);
    Assert.assertEquals(orgLevel.enumValues.length, 2);
    EnumValue enumValue = orgLevel.enumValues[0];
    Assert.assertEquals(enumValue.value, "L1");
    Assert.assertEquals(enumValue.ordinal, 1);

    // validate class
    List<StructTypeDefinition> structTypes = types.structTypesAsJavaList();
    Assert.assertEquals(1, structTypes.size());

    verifyRestoredClassType(types, "Manager");

    // validate trait
    List<HierarchicalTypeDefinition<TraitType>> traitTypes = types.traitTypesAsJavaList();
    Assert.assertEquals(1, traitTypes.size());
    HierarchicalTypeDefinition<TraitType> trait = traitTypes.get(0);
    Assert.assertEquals("SecurityClearance", trait.typeName);
    Assert.assertEquals(trait.typeName + DESCRIPTION, trait.typeDescription);
    Assert.assertEquals(1, trait.attributeDefinitions.length);
    AttributeDefinition attribute = trait.attributeDefinitions[0];
    Assert.assertEquals("level", attribute.name);
    Assert.assertEquals(DataTypes.INT_TYPE.getName(), attribute.dataTypeName);

    // validate the new types
    ts.reset();
    ts.defineTypes(types);
  }