com.ch.validator.ExecutionReportValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ch-model Show documentation
Show all versions of ch-model Show documentation
Defines model classes used for report data.
package com.ch.validator;
import org.apache.commons.lang3.StringUtils;
import com.ch.exception.ValidationException;
import com.ch.model.ExecutionReport;
import com.ch.util.DateTimeUtils;
import com.ch.util.MessageFormatterUtil;
public final class ExecutionReportValidator extends Validator {
private static final String DATE_FORMAT_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
public static void validate(ExecutionReport execution) throws ValidationException {
if (StringUtils.isEmpty(execution.getExecutionId())) {
throw new ValidationException(MessageFormatterUtil.msgForManadatoryProperty("ExecutionId"));
}
if (StringUtils.isEmpty(execution.getSubscriptionKey())) {
throw new ValidationException(MessageFormatterUtil.msgForManadatoryProperty("SubscriptionKey"));
}
if (StringUtils.isEmpty(execution.getSite())) {
throw new ValidationException(MessageFormatterUtil.msgForManadatoryProperty("Site"));
}
if (execution.getStatus() == null) {
throw new ValidationException(MessageFormatterUtil.msgForManadatoryProperty("Status"));
}
if (StringUtils.isNotEmpty(execution.getExecutionStartTime())
&& !DateTimeUtils.isValid(execution.getExecutionStartTime())) {
throw new ValidationException(
MessageFormatterUtil.msgForDateProperty("ExecutionStartTime", DATE_FORMAT_PATTERN));
}
if (StringUtils.isNotEmpty(execution.getExecutionEndTime())
&& !DateTimeUtils.isValid(execution.getExecutionEndTime())) {
throw new ValidationException(
MessageFormatterUtil.msgForDateProperty("ExecutionEndTime", DATE_FORMAT_PATTERN));
}
if (execution.getTimezone() == null) {
throw new ValidationException(MessageFormatterUtil.msgForManadatoryProperty("TimeZone"));
}
if (!StringUtils.isEmpty(execution.getSubscriptionKey())
&& isValidSubscriptionKey(execution.getSubscriptionKey())) {
throw new ValidationException(MessageFormatterUtil.msgForManadatoryProperty("SubscriptionKey"));
}
if (execution.getEnvironmentInfo() == null) {
throw new ValidationException(MessageFormatterUtil.msgForManadatoryProperty("EnvironmentInfo"));
}
if (StringUtils.isEmpty(execution.getEnvironmentInfo().getOs())) {
throw new ValidationException(MessageFormatterUtil.msgForManadatoryProperty("EnvironmentInfo.OS"));
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy