<commit_before>// BridgeDb,
// An abstraction layer for identifier mapping services, both local and online.
// Copyright 2006-2009 BridgeDb developers
// Copyright 2012-2013 <NAME>
//
// 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 org.bridgedb.bio;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Set;
import org.bridgedb.DataSource;
import org.junit.Assert;
import org.junit.Test;

/**
 *
 * @author Christian
 */
public class DataSourceTxtTest {
    
	@Test
	public void testUniqueSystemCodes() {
		DataSourceTxt.init();
		Set<String> codes = new HashSet<String>();
		Set<DataSource> sources = DataSource.getDataSources();
		Assert.assertNotSame(0, sources.size());
		for (DataSource source : sources) {
			codes.add(source.getSystemCode());
		}
		Assert.assertEquals(sources.size(), codes.size());
	}

	@Test
	public void systemCodesDoNotHaveWhitespace() {
		DataSourceTxt.init();
		Set<DataSource> sources = DataSource.getDataSources();
		Assert.assertNotSame(0, sources.size());
		for (DataSource source : sources) {
			String sysCode = source.getSystemCode();
			if (sysCode != null) {
				Assert.assertEquals(sysCode.length(), sysCode.trim().length());
				Assert.assertFalse(sysCode.contains(" "));
			}
		}
	}
    
    /**
     * Test of init and writer test method, of class DataSourceTxt.
     */
    @Test
    public void testWriteRead() throws IOException {
        System.out.println("WriteRead");
        DataSourceTxt.init();
        File generated = new File("test-data/generatedDatasources.txt");
        BufferedWriter writer = new BufferedWriter(new FileWriter(generated));
 //       DataSourceTxt.writeToBuffer(writer);
        InputStream is = new FileInputStream(generated);
        DataSourceTxt.loadInputStream(is);
    }

    @Test
    public void testWikidata() throws Exception {
    	DataSourceTxt.init();
    	DataSource wikidata = DataSource.getExistingByFullName("Wikidata");
    	Assert.assertNotNull(wikidata);
    	Assert.assertTrue(wikidata.urlPatternKnown());
    	Assert.assertEquals("Wd", wikidata.getSystemCode());
    }

    @Test
    public void testWikidataBySystemCode() throws Exception {
    	DataSourceTxt.init();
    	DataSource wikidata = DataSource.getExistingBySystemCode("Wd");
    	Assert.assertNotNull(wikidata);
    	Assert.assertTrue(wikidata.urlPatternKnown());
    	Assert.assertEquals("Wikidata", wikidata.getFullName());
    }

    @Test
    public void testChEMBL() throws Exception {
    	DataSourceTxt.init();
    	DataSource wikidata = DataSource.getExistingByFullName("ChEMBL compound");
    	Assert.assertNotNull(wikidata);
    	Assert.assertTrue(wikidata.urlPatternKnown());
    	Assert.assertEquals("Cl", wikidata.getSystemCode());
    }

    @Test
    public void testKNApSAcK() throws Exception {
    	DataSourceTxt.init();
    	DataSource wikidata = DataSource.getExistingByFullName("KNApSAcK");
    	Assert.assertNotNull(wikidata);
    	Assert.assertTrue(wikidata.urlPatternKnown());
    	Assert.assertEquals("Cks", wikidata.getSystemCode());
    }
}
<commit_msg>Update DataSourceTxtTest.java<commit_after>/*
*BridgeDb,
*An abstraction layer for identifier mapping services, both local and online.
*Copyright (c) 2006-2009 BridgeDb Developers
*Copyright (c) 2012-2013 <NAME>
*
*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 org.bridgedb.bio;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Set;
import org.bridgedb.DataSource;
import org.junit.Assert;
import static org.junit.jupiter.api.Assertions.*;


/**
 *
 * @author Christian
 */
public class DataSourceTxtTest {

	@org.junit.jupiter.api.Test
	public void testUniqueSystemCodes() {
		DataSourceTxt.init();
		Set<String> codes = new HashSet<String>();
		Set<DataSource> sources = DataSource.getDataSources();
		assertNotSame(0, sources.size());
		for (DataSource source : sources) {
			codes.add(source.getSystemCode());
		}
		assertEquals(sources.size(), codes.size());
	}

	@org.junit.jupiter.api.Test
	public void systemCodesDoNotHaveWhitespace() {
		DataSourceTxt.init();
		Set<DataSource> sources = DataSource.getDataSources();
		assertNotSame(0, sources.size());
		for (DataSource source : sources) {
			String sysCode = source.getSystemCode();
			if (sysCode != null) {
				assertEquals(sysCode.length(), sysCode.trim().length());
				assertFalse(sysCode.contains(" "));
			}
		}
	}
    
    /**
     * Test of init and writer test method, of class DataSourceTxt.
     */
	@org.junit.jupiter.api.Test
    	public void testWriteRead() throws IOException {
        System.out.println("WriteRead");
        DataSourceTxt.init();
        File generated = new File("test-data/generatedDatasources.txt");
        BufferedWriter writer = new BufferedWriter(new FileWriter(generated));
 //       DataSourceTxt.writeToBuffer(writer);
        InputStream is = new FileInputStream(generated);
        DataSourceTxt.loadInputStream(is);
    }

	@org.junit.jupiter.api.Test
    	public void testWikidata() throws Exception {
    	DataSourceTxt.init();
    	DataSource wikidata = DataSource.getExistingByFullName("Wikidata");
    	assertNotNull(wikidata);
    	assertTrue(wikidata.urlPatternKnown());
    	assertEquals("Wd", wikidata.getSystemCode());
    }

	@org.junit.jupiter.api.Test
    	public void testWikidataBySystemCode() throws Exception {
    	DataSourceTxt.init();
    	DataSource wikidata = DataSource.getExistingBySystemCode("Wd");
    	assertNotNull(wikidata);
    	assertTrue(wikidata.urlPatternKnown());
    	assertEquals("Wikidata", wikidata.getFullName());
    }

	@org.junit.jupiter.api.Test
    	public void testChEMBL() throws Exception {
    	DataSourceTxt.init();
    	DataSource wikidata = DataSource.getExistingByFullName("ChEMBL compound");
    	assertNotNull(wikidata);
    	assertTrue(wikidata.urlPatternKnown());
    	assertEquals("Cl", wikidata.getSystemCode());
    }

	@org.junit.jupiter.api.Test
    	public void testKNApSAcK() throws Exception {
    	DataSourceTxt.init();
    	DataSource wikidata = DataSource.getExistingByFullName("KNApSAcK");
    	assertNotNull(wikidata);
    	assertTrue(wikidata.urlPatternKnown());
    	assertEquals("Cks", wikidata.getSystemCode());
    }
}

{'fraction_non_alphanumeric': 0.11622924477771826, 'fraction_numerical': 0.0058918050348152114, 'mean_word_length': 4.0602981029810294, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6742263', 'n_tokens_mistral': 2328, 'n_tokens_neox': 2221, 'n_words': 526}