com.helger.peppol.testfiles.TestDocument Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of peppol-testfiles Show documentation
Show all versions of peppol-testfiles Show documentation
Library with PEPPOL test files of certain formats
/**
* Copyright (C) 2015 Philip Helger
* philip[at]helger[dot]com
*
* Licensed 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.helger.peppol.testfiles;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.helger.commons.ValueEnforcer;
import com.helger.commons.annotation.Nonempty;
import com.helger.commons.annotation.ReturnsMutableCopy;
import com.helger.commons.collection.CollectionHelper;
import com.helger.commons.string.ToStringGenerator;
/**
* This class represents a single test document
*
* @author Philip Helger
*/
public final class TestDocument
{
private final String m_sFilename;
private final Set m_aExpectedErrors = new HashSet ();
public TestDocument (@Nonnull @Nonempty final String sFilename, @Nullable final ErrorDefinition... aExpectedErrors)
{
ValueEnforcer.notEmpty (sFilename, "Filename");
m_sFilename = sFilename;
if (aExpectedErrors != null)
for (final ErrorDefinition aExpectedError : aExpectedErrors)
if (aExpectedError != null)
m_aExpectedErrors.add (aExpectedError);
}
/**
* @return The filename of the underlying resources. Neither null
* nor empty.
*/
@Nonnull
@Nonempty
public String getFilename ()
{
return m_sFilename;
}
/**
* @return The expected validation errors. Never null
but maybe
* empty.
*/
@Nonnull
@ReturnsMutableCopy
public Set getAllExpectedErrors ()
{
return CollectionHelper.newSet (m_aExpectedErrors);
}
/**
* @return true
if at least one expected error is contained
*/
public boolean hasExpectedErrors ()
{
return !m_aExpectedErrors.isEmpty ();
}
@Override
public String toString ()
{
return new ToStringGenerator (null).append ("filename", m_sFilename)
.append ("expectedErrors", m_aExpectedErrors)
.toString ();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy