private boolean isDeclaredInline(TypeAssignmentContext assignment)
  {
    return assignment.typeReference() == null;
  }
@Test
  public void testUnionDataSchemaWithAliases()
  {
    List<String> membersInDeclaredOrder = new ArrayList<>(Arrays.asList("null", "member", "article", "school",
        "organization", "company", "jobs", "courses", "fingerprint", "audio", "video"));
    Set<String> inlinedMembers = new HashSet<>(Arrays.asList("organization", "jobs", "courses", "fingerprint", "audio"));

    RecordDataSchema mainRecordSchema = (RecordDataSchema) parsePdlSchema("unionWithAliases.pdl");
    RecordDataSchema.Field resourceField = mainRecordSchema.getField("resource");

    UnionDataSchema resourceSchema = (UnionDataSchema) resourceField.getType();

    Assert.assertTrue(resourceSchema.areMembersAliased());
    Assert.assertEquals(resourceSchema.getMembers().size(), membersInDeclaredOrder.size());

    int index = 0;
    for (UnionDataSchema.Member member: resourceSchema.getMembers())
    {
      Assert.assertFalse(member.hasError());

      boolean isNonNullMember = (member.getType().getDereferencedType() != DataSchema.Type.NULL);

      // Only non-null members should be aliased
      Assert.assertEquals(member.hasAlias(), isNonNullMember);

      String memberKey = member.getUnionMemberKey();
      DataSchema type = member.getType();

      // Verify the member's getUnionMemberKey() is same as the member alias (for non null members)
      Assert.assertEquals(memberKey, isNonNullMember ? member.getAlias() : type.getUnionMemberKey());

      // Verify the order is maintained as declared in the union definition
      Assert.assertEquals(memberKey, membersInDeclaredOrder.get(index));

      // Verify the inlined member definition is captured correctly
      Assert.assertEquals(member.isDeclaredInline(), inlinedMembers.contains(memberKey));

      // Verify the type, doc and other properties
      Assert.assertEquals(type, resourceSchema.getTypeByMemberKey(memberKey));
      Assert.assertEquals(member.getDoc(), isNonNullMember ? memberKey + " doc" : "");
      Assert.assertEquals(member.getProperties().containsKey("inlined"), member.isDeclaredInline());

      index++;
    }
  }