001/*
002 * Copyright 2020 Global Biodiversity Information Facility (GBIF)
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.gbif.api.model.crawler;
017
018import java.util.Arrays;
019import java.util.Collections;
020
021import org.junit.jupiter.api.Test;
022
023import static org.junit.jupiter.api.Assertions.assertFalse;
024import static org.junit.jupiter.api.Assertions.assertThrows;
025import static org.junit.jupiter.api.Assertions.assertTrue;
026
027public class GenericValidationReportTest {
028
029  @Test
030  public void testConstructor() {
031    assertThrows(NullPointerException.class, () -> new GenericValidationReport(10, true, null, null));
032  }
033
034  @Test
035  public void testConstructor2() {
036    assertThrows(NullPointerException.class, () -> new GenericValidationReport(10, true, Collections.emptyList(), null));
037  }
038
039  @Test
040  public void testConstructor3() {
041    assertThrows(NullPointerException.class, () -> new GenericValidationReport(10, true, null, Collections.emptyList()));
042  }
043
044  @Test
045  public void testIsValid() {
046    assertTrue(new GenericValidationReport(10, true, Collections.emptyList(), Collections.emptyList()).isValid());
047    assertTrue(new GenericValidationReport(0, true, Collections.emptyList(), Collections.emptyList()).isValid());
048    assertFalse(new GenericValidationReport(10, true, Collections.emptyList(), Collections.singletonList(1)).isValid());
049    assertFalse(new GenericValidationReport(10, true, Collections.emptyList(), Arrays.asList(1,2,3,4)).isValid());
050    assertFalse(new GenericValidationReport(10, true, Collections.singletonList("r32"),
051      Arrays.asList(1, 2)).isValid());
052    assertFalse(new GenericValidationReport(10, true, Collections.singletonList("r32"), Collections.emptyList()).isValid());
053  }
054}