<commit_before>package org.rcsb.mmtf.decoder;

import org.junit.Test;
import org.rcsb.mmtf.dataholders.MmtfBean;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;


import java.io.IOException;
import java.nio.file.Paths;

/**
 * Test the reader utils class functions work.
 * @author <NAME>
 *
 */
public class TestReaderUtils {
	
	/**
	 * Test we can decompress a gzipped byte array.
	 */
	@Test
	public void testGzipDecompress() throws IOException {
		
		// Data derived using Python to get bytes and gzip to compres
		byte[] uncompressed = new byte[] {65, 66, 67, 68, 10};
		byte[] compressed = new byte[] {31, (byte) 139,
               8,
               8,
               45,
               (byte)  174,
               15,
               87,
               0,
               3,
               109,
               101,
               46,
               116,
               120,
               116,
               0,
               115,
               116,
               114,
               118,
               (byte)  225,
               2,
               0,
               (byte)  212,
               70,
               (byte)  176,
               (byte)  148,
               5,
               0,
               0,
               0};
		// Check they  are the same
		assertArrayEquals(ReaderUtils.deflateGzip(compressed), uncompressed);
		
	}
	
	/**
	 * Test that we can't gzip decompress non-gzipped data.
	 */
	@Test
	public void testGzipDecompressText() throws IOException {
		// Test that decomprss text returns null
		byte[] uncompressed = new byte[] {65, 66, 67, 68, 10};
		assertEquals(null,ReaderUtils.deflateGzip(uncompressed));
	}

	
	/**
	 * Test that we can read an mmtf file into an MmmtfBean
	 * @throws IOException error accesing the file
	 */
	@Test 
	public void testReadFromFile() throws IOException {
		ClassLoader classLoader = getClass().getClassLoader();
		MmtfBean mmtfBean = ReaderUtils.getDataFromFile(Paths.get(classLoader.getResource("mmtf/4cup.mmtf").getFile()));
		assertNotEquals(mmtfBean, null);
		assertEquals(mmtfBean.getDepositionDate(), "2014-03-21");
	}
}<commit_msg>Fixing test after exception refactoring<commit_after>package org.rcsb.mmtf.decoder;

import org.junit.Test;
import org.rcsb.mmtf.dataholders.MmtfBean;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;


import java.io.IOException;
import java.nio.file.Paths;

/**
 * Test the reader utils class functions work.
 * @author <NAME>
 *
 */
public class TestReaderUtils {
	
	/**
	 * Test we can decompress a gzipped byte array.
	 */
	@Test
	public void testGzipDecompress() throws IOException {
		
		// Data derived using Python to get bytes and gzip to compres
		byte[] uncompressed = new byte[] {65, 66, 67, 68, 10};
		byte[] compressed = new byte[] {31, (byte) 139,
               8,
               8,
               45,
               (byte)  174,
               15,
               87,
               0,
               3,
               109,
               101,
               46,
               116,
               120,
               116,
               0,
               115,
               116,
               114,
               118,
               (byte)  225,
               2,
               0,
               (byte)  212,
               70,
               (byte)  176,
               (byte)  148,
               5,
               0,
               0,
               0};
		// Check they  are the same
		assertArrayEquals(ReaderUtils.deflateGzip(compressed), uncompressed);
		
	}
	
	/**
	 * Test that we can't gzip decompress non-gzipped data.
	 */
	@Test(expected=IOException.class)
	public void testGzipDecompressText() throws IOException {
		// Test that decomprss text returns null
		byte[] uncompressed = new byte[] {65, 66, 67, 68, 10};
		ReaderUtils.deflateGzip(uncompressed);
		//assertEquals(null,ReaderUtils.deflateGzip(uncompressed));
	}

	
	/**
	 * Test that we can read an mmtf file into an MmmtfBean
	 * @throws IOException error accesing the file
	 */
	@Test 
	public void testReadFromFile() throws IOException {
		ClassLoader classLoader = getClass().getClassLoader();
		MmtfBean mmtfBean = ReaderUtils.getDataFromFile(Paths.get(classLoader.getResource("mmtf/4cup.mmtf").getFile()));
		assertNotEquals(mmtfBean, null);
		assertEquals(mmtfBean.getDepositionDate(), "2014-03-21");
	}
}
{'fraction_non_alphanumeric': 0.10086647411686292, 'fraction_numerical': 0.04310153299266829, 'mean_word_length': 1.8314465408805032, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4333802', 'n_tokens_mistral': 1562, 'n_tokens_neox': 1297, 'n_words': 359}