<commit_before>package thredds.metadata;

import org.junit.Test;
import thredds.catalog.InvCatalogFactory;
import thredds.catalog.InvCatalogImpl;
import thredds.catalog.InvDatasetImpl;
import thredds.catalog.ThreddsMetadata;
import ucar.nc2.Attribute;
import ucar.nc2.NetcdfFile;
import ucar.nc2.constants.FeatureType;
import ucar.nc2.thredds.MetadataExtractorAcdd;
import ucar.nc2.time.CalendarDate;
import ucar.nc2.units.DateRange;
import ucar.unidata.test.util.TestDir;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;

import static org.junit.Assert.assertEquals;

/**
 * Test MetadataExtractor and MetadataExtractorAcdd
 *
 * @author caron
 * @since 11/1/13
 */
public class TestMetadataExtractor {

  @Test
  public void testMetadataExtractorAcdd() throws IOException, URISyntaxException {
    String filename = TestDir.cdmUnitTestDir + "agg/pointFeatureCollection/netCDFbuoydata/BOD001_000_20050627_20051109.nc";
    NetcdfFile ncfile = NetcdfFile.open(filename);

    InvCatalogImpl cat = new InvCatalogImpl("testAcdd", "1.0.5", new URI("file:baseURI"));
    InvDatasetImpl ds = new InvDatasetImpl(null, "testAcdd");
    MetadataExtractorAcdd acdd = new MetadataExtractorAcdd(Attribute.makeMap(ncfile.getGlobalAttributes()), ds);
    acdd.extract();
    ncfile.close();

    cat.addDataset(ds);
    cat.finish();
    InvCatalogFactory fac = InvCatalogFactory.getDefaultFactory(false);
    System.out.printf("%s%n", fac.writeXML(cat));
<commit_msg>fix unit test<commit_after>package thredds.metadata;

import org.junit.Test;
import thredds.catalog.InvCatalogFactory;
import thredds.catalog.InvCatalogImpl;
import thredds.catalog.InvDatasetImpl;
import thredds.catalog.ThreddsMetadata;
import ucar.nc2.Attribute;
import ucar.nc2.NetcdfFile;
import ucar.nc2.constants.FeatureType;
import ucar.nc2.thredds.MetadataExtractorAcdd;
import ucar.nc2.time.CalendarDate;
import ucar.nc2.units.DateRange;
import ucar.unidata.test.util.TestDir;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;

import static org.junit.Assert.assertEquals;

/**
 * Test MetadataExtractor and MetadataExtractorAcdd
 *
 * @author caron
 * @since 11/1/13
 */
public class TestMetadataExtractor {

  @Test
  public void testMetadataExtractorAcdd() throws IOException, URISyntaxException {
    String filename = TestDir.cdmUnitTestDir + "agg/pointFeatureCollection/netCDFbuoydata/BOD001_000_20050627_20051109.nc";
    NetcdfFile ncfile = NetcdfFile.open(filename);

    InvCatalogImpl cat = new InvCatalogImpl("testAcdd", "1.0.5", new URI("file:baseURI"));
    InvDatasetImpl ds = new InvDatasetImpl(null, "testAcdd");
    MetadataExtractorAcdd acdd = new MetadataExtractorAcdd(Attribute.makeMap(ncfile.getGlobalAttributes()), ds, ds.getLocalMetadataInheritable());
    acdd.extract();
    ncfile.close();

    cat.addDataset(ds);
    cat.finish();
    InvCatalogFactory fac = InvCatalogFactory.getDefaultFactory(false);
    System.out.printf("%s%n", fac.writeXML(cat));

{'fraction_non_alphanumeric': 0.10966057441253264, 'fraction_numerical': 0.02349869451697128, 'mean_word_length': 5.67755991285403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6035891', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1027, 'n_words': 179}