class ProcessEntityParser extends EntityParser<Process> {

    @Override
    public void validate(Process process) throws IvoryException {
        if(process.getTimezone() == null)
            process.setTimezone(TimeZone.getTimeZone("UTC"));

        // check if dependent entities exists
        Set<String> clusters = new HashSet<String>();
        for (org.apache.ivory.entity.v0.process.Cluster cluster : process.getClusters().getClusters()) {
            String clusterName = cluster.getName();
			if (!clusters.add(cluster.getName())) {
				throw new ValidationException("Cluster: " + cluster.getName()
						+ " is defined more than once for process: "+process.getName());
			}
            validateEntityExists(EntityType.CLUSTER, clusterName);
            validateProcessValidity(cluster.getValidity().getStart(), cluster.getValidity().getEnd());
            validateHDFSpaths(process, clusterName);

            if (process.getInputs() != null) {
                for (Input input : process.getInputs().getInputs()) {
                    validateEntityExists(EntityType.FEED, input.getFeed());
                    Feed feed = (Feed) ConfigurationStore.get().get(EntityType.FEED, input.getFeed());
                    CrossEntityValidations.validateFeedDefinedForCluster(feed, clusterName);
                    CrossEntityValidations.validateFeedRetentionPeriod(input.getStart(), feed, clusterName);
                    CrossEntityValidations.validateInstanceRange(process, input, feed);
                    if (input.getPartition() != null) {
                        CrossEntityValidations.validateInputPartition(input, feed);
                    }
                }
            }

            if (process.getOutputs() != null) {
                for (Output output : process.getOutputs().getOutputs()) {
                    validateEntityExists(EntityType.FEED, output.getFeed());
                    Feed feed = (Feed) ConfigurationStore.get().get(EntityType.FEED, output.getFeed());
                    CrossEntityValidations.validateFeedDefinedForCluster(feed, clusterName);
                    CrossEntityValidations.validateInstance(process, output, feed);
                }
            }
        }
        validateDatasetName(process.getInputs(), process.getOutputs());
        validateLateInputs(process);
    }

}

class ProcessEntityParserTest extends EntityParser<Process> {

	private final ProcessEntityParser parser;
	private String INVALID_PROCESS_XML;

	@Test(expectedExceptions = ValidationException.class)
	public void testInvalidProcessValidity() throws Exception {

		Process process = parser
				.parseAndValidate((ProcessEntityParserTest.class
						.getResourceAsStream(PROCESS_XML)));
		process.getClusters().getClusters().get(0).getValidity().setStart(SchemaHelper.parseDateUTC("2011-12-31T00:00Z"));
		parser.validate(process);
	}

}