// Path: cm-schema/src/main/java/com/cloudera/parcel/descriptors/ParcelDescriptor.java
// public interface ParcelDescriptor {
// 
//   @NotNull
//   @Range(min = 1, max = 1)
//   Integer getSchema_version();
// 
//   @NotBlank
//   @Pattern(regexp="^((?!-).)*$", message="{custom.validation.constraints.ParcelName.message}")
//   String getName();
// 
//   @NotBlank
//   String getVersion();
// 
//   Map<String, String> getExtraVersionInfo();
// 
//   @NotNull
//   Boolean getSetActiveSymlink();
// 
//   String getDepends();
// 
//   String getReplaces();
// 
//   String getConflicts();
// 
//   Set<String> getProvides();
// 
//   @Valid
//   @NotNull
//   ScriptsDescriptor getScripts();
// 
//   @UniqueField("name")
//   @Valid
//   @NotNull
//   Set<PackageDescriptor> getPackages();
// 
//   @UniqueField("name")
//   @Valid
//   @NotNull
//   Set<ComponentDescriptor> getComponents();
// 
//   @Valid
//   @NotNull
//   Map<String, UserDescriptor> getUsers();
// 
//   @NotNull
//   Set<String> getGroups();
// 
//   ServicesRestartDescriptor getServicesRestartInfo();
// }
// 
// Path: cm-schema/src/main/java/com/cloudera/parcel/descriptors/VersionServicesRestartDescriptor.java
// public interface VersionServicesRestartDescriptor {
// 
//   enum Scope {
//     SERVICE_ONLY,
//     DEPENDENTS_ONLY,
//     SERVICE_AND_DEPENDENTS
//   }
// 
//   /**
//    * Contains a map of service type to {@link Scope}
//    * @return a map of service type to {@link Scope}
//    */
//   @NotNull
//   Map<String, Scope> getServiceInfo();
// 
//   /**
//    * Parent parcel version of this version descriptor.
//    *
//    * Can be null, in which case this is determined to be the oldest version
//    * supported from which the restart information will be used for selective restarts.
//    *
//    * @return parent version, if specified.
//    */
//   String getParentVersion();
// 
//   /**
//    * Child parcel version of this version descriptor.
//    *
//    * Can be null, in which case this is determined to be the newest version
//    * supported from which the restart information will be used for selective restarts.
//    *
//    * @return child version, if specified.
//    */
//   String getChildVersion();
// }
// 
// Path: cm-schema/src/main/java/com/cloudera/parcel/descriptors/VersionServicesRestartDescriptor.java
// enum Scope {
//   SERVICE_ONLY,
//   DEPENDENTS_ONLY,
//   SERVICE_AND_DEPENDENTS
// }


import java.util.Set;
import org.junit.Test;
import static org.junit.Assert.*;
import com.cloudera.parcel.descriptors.ComponentDescriptor;
import com.cloudera.parcel.descriptors.PackageDescriptor;
import com.cloudera.parcel.descriptors.ParcelDescriptor;
import com.cloudera.parcel.descriptors.UserDescriptor;
import com.cloudera.parcel.descriptors.VersionServicesRestartDescriptor;
import com.cloudera.parcel.descriptors.VersionServicesRestartDescriptor.Scope;
import com.cloudera.parcel.validation.ParcelTestUtils;
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import java.io.IOException;
import java.util.Map;

    Map<String, UserDescriptor> users = parcel.getUsers();
    assertEquals(2, users.size());

    UserDescriptor hdfs = users.get("hdfs");
    assertNotNull(hdfs);
    assertEquals("Hadoop HDFS", hdfs.getLongname());
    assertEquals("/var/lib/hadoop-hdfs", hdfs.getHome());
    assertEquals("/bin/bash", hdfs.getShell());
    assertEquals(ImmutableSet.of("hadoop"), hdfs.getExtra_groups());

    UserDescriptor impala = users.get("impala");
    assertEquals("Impala", impala.getLongname());
    assertEquals("/var/run/impala", impala.getHome());
    assertEquals("/bin/bash", impala.getShell());
    assertEquals(ImmutableSet.of("hive", "hdfs"), impala.getExtra_groups());

    assertEquals(ImmutableSet.of("hadoop"), parcel.getGroups());

    assertNotNull(parcel.getServicesRestartInfo());
    assertNotNull(parcel.getServicesRestartInfo().getVersionInfo());

    Map<String, VersionServicesRestartDescriptor> versionServicesRestartDescriptorMap =
      parcel.getServicesRestartInfo().getVersionInfo();
    assertEquals(3, versionServicesRestartDescriptorMap.size());
    assertTrue(versionServicesRestartDescriptorMap.containsKey("5.0.0-0.cdh5b2.p0.282"));
    assertTrue(versionServicesRestartDescriptorMap.containsKey("5.0.0-0.cdh5b2.p0.281"));
    assertTrue(versionServicesRestartDescriptorMap.containsKey("5.0.0-0.cdh5b2.p0.280"));
    assertTrue(versionServicesRestartDescriptorMap.get("5.0.0-0.cdh5b2.p0.282").getParentVersion().equals("5.0.0-0.cdh5b2.p0.281"));
    assertTrue(versionServicesRestartDescriptorMap.get("5.0.0-0.cdh5b2.p0.282").getServiceInfo().containsKey("IMPALA"));
// Path: cm-schema/src/main/java/com/cloudera/parcel/descriptors/ParcelDescriptor.java
// public interface ParcelDescriptor {
// 
//   @NotNull
//   @Range(min = 1, max = 1)
//   Integer getSchema_version();
// 
//   @NotBlank
//   @Pattern(regexp="^((?!-).)*$", message="{custom.validation.constraints.ParcelName.message}")
//   String getName();
// 
//   @NotBlank
//   String getVersion();
// 
//   Map<String, String> getExtraVersionInfo();
// 
//   @NotNull
//   Boolean getSetActiveSymlink();
// 
//   String getDepends();
// 
//   String getReplaces();
// 
//   String getConflicts();
// 
//   Set<String> getProvides();
// 
//   @Valid
//   @NotNull
//   ScriptsDescriptor getScripts();
// 
//   @UniqueField("name")
//   @Valid
//   @NotNull
//   Set<PackageDescriptor> getPackages();
// 
//   @UniqueField("name")
//   @Valid
//   @NotNull
//   Set<ComponentDescriptor> getComponents();
// 
//   @Valid
//   @NotNull
//   Map<String, UserDescriptor> getUsers();
// 
//   @NotNull
//   Set<String> getGroups();
// 
//   ServicesRestartDescriptor getServicesRestartInfo();
// }
// 
// Path: cm-schema/src/main/java/com/cloudera/parcel/descriptors/VersionServicesRestartDescriptor.java
// public interface VersionServicesRestartDescriptor {
// 
//   enum Scope {
//     SERVICE_ONLY,
//     DEPENDENTS_ONLY,
//     SERVICE_AND_DEPENDENTS
//   }
// 
//   /**
//    * Contains a map of service type to {@link Scope}
//    * @return a map of service type to {@link Scope}
//    */
//   @NotNull
//   Map<String, Scope> getServiceInfo();
// 
//   /**
//    * Parent parcel version of this version descriptor.
//    *
//    * Can be null, in which case this is determined to be the oldest version
//    * supported from which the restart information will be used for selective restarts.
//    *
//    * @return parent version, if specified.
//    */
//   String getParentVersion();
// 
//   /**
//    * Child parcel version of this version descriptor.
//    *
//    * Can be null, in which case this is determined to be the newest version
//    * supported from which the restart information will be used for selective restarts.
//    *
//    * @return child version, if specified.
//    */
//   String getChildVersion();
// }
// 
// Path: cm-schema/src/main/java/com/cloudera/parcel/descriptors/VersionServicesRestartDescriptor.java
// enum Scope {
//   SERVICE_ONLY,
//   DEPENDENTS_ONLY,
//   SERVICE_AND_DEPENDENTS
// }


// Path: cm-schema/src/test/java/com/cloudera/parcel/components/JsonParcelParserTest.java
import java.util.Set;
import org.junit.Test;
import static org.junit.Assert.*;
import com.cloudera.parcel.descriptors.ComponentDescriptor;
import com.cloudera.parcel.descriptors.PackageDescriptor;
import com.cloudera.parcel.descriptors.ParcelDescriptor;
import com.cloudera.parcel.descriptors.UserDescriptor;
import com.cloudera.parcel.descriptors.VersionServicesRestartDescriptor;
import com.cloudera.parcel.descriptors.VersionServicesRestartDescriptor.Scope;
import com.cloudera.parcel.validation.ParcelTestUtils;
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import java.io.IOException;
import java.util.Map;


    Map<String, UserDescriptor> users = parcel.getUsers();
    assertEquals(2, users.size());

    UserDescriptor hdfs = users.get("hdfs");
    assertNotNull(hdfs);
    assertEquals("Hadoop HDFS", hdfs.getLongname());
    assertEquals("/var/lib/hadoop-hdfs", hdfs.getHome());
    assertEquals("/bin/bash", hdfs.getShell());
    assertEquals(ImmutableSet.of("hadoop"), hdfs.getExtra_groups());

    UserDescriptor impala = users.get("impala");
    assertEquals("Impala", impala.getLongname());
    assertEquals("/var/run/impala", impala.getHome());
    assertEquals("/bin/bash", impala.getShell());
    assertEquals(ImmutableSet.of("hive", "hdfs"), impala.getExtra_groups());

    assertEquals(ImmutableSet.of("hadoop"), parcel.getGroups());

    assertNotNull(parcel.getServicesRestartInfo());
    assertNotNull(parcel.getServicesRestartInfo().getVersionInfo());

    Map<String, VersionServicesRestartDescriptor> versionServicesRestartDescriptorMap =
      parcel.getServicesRestartInfo().getVersionInfo();
    assertEquals(3, versionServicesRestartDescriptorMap.size());
    assertTrue(versionServicesRestartDescriptorMap.containsKey("5.0.0-0.cdh5b2.p0.282"));
    assertTrue(versionServicesRestartDescriptorMap.containsKey("5.0.0-0.cdh5b2.p0.281"));
    assertTrue(versionServicesRestartDescriptorMap.containsKey("5.0.0-0.cdh5b2.p0.280"));
    assertTrue(versionServicesRestartDescriptorMap.get("5.0.0-0.cdh5b2.p0.282").getParentVersion().equals("5.0.0-0.cdh5b2.p0.281"));
    assertTrue(versionServicesRestartDescriptorMap.get("5.0.0-0.cdh5b2.p0.282").getServiceInfo().containsKey("IMPALA"));
    assertTrue(versionServicesRestartDescriptorMap.get("5.0.0-0.cdh5b2.p0.282").getServiceInfo().containsValue(Scope.DEPENDENTS_ONLY));