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.Collections; 019import java.util.UUID; 020 021import org.junit.jupiter.api.Test; 022 023import static org.junit.jupiter.api.Assertions.assertFalse; 024import static org.junit.jupiter.api.Assertions.assertTrue; 025 026public class DwcaValidationReportTest { 027 028 @Test 029 public void testIsValid() { 030 assertTrue(new DwcaValidationReport(UUID.randomUUID(), 031 new OccurrenceValidationReport(10, 10, 0, 10, 0, true), 032 new GenericValidationReport(10, true, Collections.emptyList(), Collections.emptyList()), null 033 ).isValid()); 034 035 // this is a regular case with Plazi checklist archives. 036 // Occurrences are declared in meta.xml but the data file is empty 037 // needs to validate for checklist indexing to happen! 038 assertTrue(new DwcaValidationReport(UUID.randomUUID(), 039 new OccurrenceValidationReport(0, 0, 0, 0, 0, true), 040 new GenericValidationReport(10, true, Collections.emptyList(), Collections.emptyList()), null 041 ).isValid()); 042 043 assertTrue(new DwcaValidationReport(UUID.randomUUID(), 044 new GenericValidationReport(10, true, Collections.emptyList(), Collections.emptyList()) 045 ).isValid()); 046 047 assertTrue(new DwcaValidationReport(UUID.randomUUID(), 048 new OccurrenceValidationReport(10, 4, 0, 10, 0, true) 049 ).isValid()); 050 051 assertFalse(new DwcaValidationReport(UUID.randomUUID(), 052 new OccurrenceValidationReport(10, 4, 0, 6, 0, true), 053 new GenericValidationReport(10, true, Collections.emptyList(), Collections.emptyList()), null 054 ).isValid()); 055 056 assertFalse(new DwcaValidationReport(UUID.randomUUID(), 057 new OccurrenceValidationReport(10, 10, 0, 10, 0, true), 058 new GenericValidationReport(10, true, Collections.singletonList("r32"), Collections.emptyList()), null 059 ).isValid()); 060 061 assertFalse(new DwcaValidationReport(UUID.randomUUID(), 062 new OccurrenceValidationReport(10, 10, 0, 10, 0, true), 063 new GenericValidationReport(10, true, Collections.emptyList(), Collections.singletonList(32)), null 064 ).isValid()); 065 066 assertFalse(new DwcaValidationReport(UUID.randomUUID(), "Dont like the smell").isValid()); 067 } 068}