<commit_before>/*
*
* author:  gvenzl
* created: 2 Apr 2016
*
* name: FileRepositoryTest.java
*
*/

package com.dbpm.repository;

import static org.junit.Assert.*;

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

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class FileRepositoryTest{

	static String TESTPACKAGE = "Testpackage-1.0.0-oracle.dbpgk";
	String repoName = "testrepo.xml";
	String storeName = "store";
	
	FileRepository repo;
	
	@Before
	public void setup() {
		repo = new FileRepository(repoName, storeName);
	}
	
	@Test
	public void test_createRepo() {
		assertTrue(repo.createRepo());
	}
	
	@Test
	public void test_checkRepo() {
		assertTrue(repo.checkRepo());
	}
	
	@Test
	public void test_writeEntry() {
		repo.createRepo();
		assertTrue(repo.writeEntry("testDB", "TestSchema", new Package(TESTPACKAGE)));
	}
	
	@Test
	public void test_isPackageInstalledPositive() throws Exception{
		repo.createRepo();
		assertTrue(repo.writeEntry("testDB", "TestSchema", new Package(TESTPACKAGE)));
		assertTrue(repo.isPackageInstalled("testDB", "TestSchema", new Package(TESTPACKAGE)));
	}
	
	@Test
	public void test_isPackageInstalledNegative() throws Exception {
		repo.createRepo();
		assertFalse(repo.isPackageInstalled("testDB", "TestSchema", new Package(TESTPACKAGE)));
	}
	
	@Test
	public void test_savePackage() throws IOException {
		repo.createRepo();
		byte[] content = Files.readAllBytes(Paths.get(repoName));
		
		repo.savePackage(new Package(TESTPACKAGE), content);
	}
	<commit_msg>Better negative tests for FileRepository isPackageInstalled<commit_after>/*
*
* author:  gvenzl
* created: 2 Apr 2016
*
* name: FileRepositoryTest.java
*
*/

package com.dbpm.repository;

import static org.junit.Assert.*;

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

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class FileRepositoryTest{

	static String TESTPACKAGE = "Testpackage-1.0.0-oracle.dbpgk";
	String repoName = "testrepo.xml";
	String storeName = "store";
	
	FileRepository repo;
	
	@Before
	public void setup() {
		repo = new FileRepository(repoName, storeName);
	}
	
	@Test
	public void test_createRepo() {
		assertTrue(repo.createRepo());
	}
	
	@Test
	public void test_checkRepo() {
		assertTrue(repo.checkRepo());
	}
	
	@Test
	public void test_writeEntry() {
		repo.createRepo();
		assertTrue(repo.writeEntry("testDB", "TestSchema", new Package(TESTPACKAGE)));
	}
	
	@Test
	public void test_isPackageInstalledPositive() throws Exception{
		repo.createRepo();
		assertTrue(repo.writeEntry("testDB", "TestSchema", new Package(TESTPACKAGE)));
		assertTrue(repo.isPackageInstalled("testDB", "TestSchema", new Package(TESTPACKAGE)));
	}
	
	@Test
	public void test_isPackageInstalledNegative() throws Exception {
		repo.createRepo();
		// No database or schema exist
		assertFalse(repo.isPackageInstalled("testDB", "TestSchema", new Package(TESTPACKAGE)));
		// No schema exists but database does already exist
		assertTrue(repo.writeEntry("testDB", "TestSchema", new Package(TESTPACKAGE)));
		assertFalse(repo.isPackageInstalled("testDB", "OtherTestSchema", new Package(TESTPACKAGE)));
		// Schema and DB exist but package does not exist
		assertFalse(repo.isPackageInstalled("testDB", "TestSchema", new Package("dummy-9.9.9-mysql.dbpgk")));
	}
	
	@Test
	public void test_savePackage() throws IOException {
		repo.createRepo();
		byte[] content = Files.readAllBytes(Paths.get(repoName));
		
		repo.savePackage(new Package(TESTPACKAGE), content);
	}
	
{'fraction_non_alphanumeric': 0.12969564025226213, 'fraction_numerical': 0.005209761447765287, 'mean_word_length': 5.300518134715026, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '6269247', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1163, 'n_words': 257}