// Path: cm-schema/src/main/java/com/cloudera/parcel/descriptors/ParcelInfoDescriptor.java
// public interface ParcelInfoDescriptor {
// 
//   @NotBlank
//   String getParcelName();
// 
//   @NotBlank
//   String getHash();
// 
//   @UniqueField("name")
//   @Valid
//   @NotNull
//   List<ComponentDescriptor> getComponents();
// 
//   Instant getReleased();
// 
//   String getDepends();
// 
//   String getReplaces();
// 
//   String getConflicts();
// 
//   String getReleaseNotes();
// 
//   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 static org.junit.Assert.*;
import com.cloudera.parcel.descriptors.ManifestDescriptor;
import com.cloudera.parcel.descriptors.ParcelInfoDescriptor;
import com.cloudera.parcel.descriptors.VersionServicesRestartDescriptor;
import com.cloudera.parcel.descriptors.VersionServicesRestartDescriptor.Scope;
import com.cloudera.parcel.validation.ParcelTestUtils;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.joda.time.Instant;
import org.junit.Test;
// Licensed to Cloudera, Inc. under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  Cloudera, Inc. licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.cloudera.parcel.components;





public class JsonManifestParserTest {

  private JsonManifestParser parser = new JsonManifestParser();

  @Test
  public void testParseGoodFile() throws IOException {
    ManifestDescriptor descriptor = parser.parse(ParcelTestUtils.getParcelJson("good_manifest.json"));
    assertEquals(new Instant(1392073012), descriptor.getLastUpdated());

    List<ParcelInfoDescriptor> parcels = descriptor.getParcels();
    assertEquals(3, parcels.size());

    ParcelInfoDescriptor parcelInfo = parcels.get(0);
    assertEquals("CDH-5.0.0-0.cdh5b2.p0.282-wheezy.parcel", parcelInfo.getParcelName());
    assertEquals("ec6e65de6e192949fd095b391b9e3b8b2d13e780", parcelInfo.getHash());
    assertEquals("IMPALA, SOLR, SPARK", parcelInfo.getReplaces());
    assertEquals(27, parcelInfo.getComponents().size());

// Path: cm-schema/src/main/java/com/cloudera/parcel/descriptors/ParcelInfoDescriptor.java
// public interface ParcelInfoDescriptor {
// 
//   @NotBlank
//   String getParcelName();
// 
//   @NotBlank
//   String getHash();
// 
//   @UniqueField("name")
//   @Valid
//   @NotNull
//   List<ComponentDescriptor> getComponents();
// 
//   Instant getReleased();
// 
//   String getDepends();
// 
//   String getReplaces();
// 
//   String getConflicts();
// 
//   String getReleaseNotes();
// 
//   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/JsonManifestParserTest.java
import static org.junit.Assert.*;
import com.cloudera.parcel.descriptors.ManifestDescriptor;
import com.cloudera.parcel.descriptors.ParcelInfoDescriptor;
import com.cloudera.parcel.descriptors.VersionServicesRestartDescriptor;
import com.cloudera.parcel.descriptors.VersionServicesRestartDescriptor.Scope;
import com.cloudera.parcel.validation.ParcelTestUtils;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.joda.time.Instant;
import org.junit.Test;

// Licensed to Cloudera, Inc. under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  Cloudera, Inc. licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.cloudera.parcel.components;





public class JsonManifestParserTest {

  private JsonManifestParser parser = new JsonManifestParser();

  @Test
  public void testParseGoodFile() throws IOException {
    ManifestDescriptor descriptor = parser.parse(ParcelTestUtils.getParcelJson("good_manifest.json"));
    assertEquals(new Instant(1392073012), descriptor.getLastUpdated());

    List<ParcelInfoDescriptor> parcels = descriptor.getParcels();
    assertEquals(3, parcels.size());

    ParcelInfoDescriptor parcelInfo = parcels.get(0);
    assertEquals("CDH-5.0.0-0.cdh5b2.p0.282-wheezy.parcel", parcelInfo.getParcelName());
    assertEquals("ec6e65de6e192949fd095b391b9e3b8b2d13e780", parcelInfo.getHash());
    assertEquals("IMPALA, SOLR, SPARK", parcelInfo.getReplaces());
    assertEquals(27, parcelInfo.getComponents().size());

    parcelInfo = parcels.get(1);