<commit_before>package org.openlca.io.ecospold2.input;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openlca.core.database.CategoryDao;
import org.openlca.core.database.IDatabase;
import org.openlca.core.model.Category;
import org.openlca.core.model.ModelType;
import org.openlca.io.TestSession;
import org.openlca.io.ecospold2.input.IsicTree.IsicNode;

public class IsicTreeTest {

	private IsicTree tree;

	@Before
	public void setUp() {
		tree = IsicTree.fromFile(this.getClass().getResourceAsStream(
				"isic_codes_rev4.txt"));
	}

	@Test
	public void testFindNode() {
		IsicNode node = tree.findNode("9492");
		Assert.assertEquals("Activities of political organizations",
				node.getName());
		Assert.assertEquals("949", node.getParent().getCode());
		Assert.assertEquals("94", node.getParent().getParent().getCode());
		Assert.assertEquals("S", node.getParent().getParent().getParent()
				.getCode());
	}

	@Test
	public void testSyncCategories() {
		IDatabase database = TestSession.getDerbyDatabase();
		CategoryDao dao = new CategoryDao(database);
		Category cat = new Category();
		cat.setName("0121:Growing of grapes");
		cat.setModelType(ModelType.FLOW);
		cat = dao.insert(cat);
		new IsicCategoryTreeSync(database, ModelType.FLOW).run();
		cat = dao.getForId(cat.getId());
		Assert.assertNotNull(cat.getParentCategory());
		Assert.assertEquals("012:Growing of perennial crops", cat
				.getParentCategory().getName());
	}

}<commit_msg>isic tree: added test for process categories<commit_after>package org.openlca.io.ecospold2.input;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openlca.core.database.CategoryDao;
import org.openlca.core.database.IDatabase;
import org.openlca.core.model.Category;
import org.openlca.core.model.ModelType;
import org.openlca.io.TestSession;
import org.openlca.io.ecospold2.input.IsicTree.IsicNode;

public class IsicTreeTest {

	private IsicTree tree;

	@Before
	public void setUp() {
		tree = IsicTree.fromFile(this.getClass().getResourceAsStream(
				"isic_codes_rev4.txt"));
	}

	@Test
	public void testFindNode() {
		IsicNode node = tree.findNode("9492");
		Assert.assertEquals("Activities of political organizations",
				node.getName());
		Assert.assertEquals("949", node.getParent().getCode());
		Assert.assertEquals("94", node.getParent().getParent().getCode());
		Assert.assertEquals("S", node.getParent().getParent().getParent()
				.getCode());
	}

	@Test
	public void testSyncFlowCategories() {
		IDatabase database = TestSession.getDerbyDatabase();
		CategoryDao dao = new CategoryDao(database);
		Category cat = new Category();
		cat.setName("0121:Growing of grapes");
		cat.setModelType(ModelType.FLOW);
		cat = dao.insert(cat);
		new IsicCategoryTreeSync(database, ModelType.FLOW).run();
		cat = dao.getForId(cat.getId());
		Assert.assertNotNull(cat.getParentCategory());
		Assert.assertEquals("012:Growing of perennial crops", cat
				.getParentCategory().getName());
	}

	@Test
	public void testSyncProcessCategories() {
		IDatabase database = TestSession.getDerbyDatabase();
		CategoryDao dao = new CategoryDao(database);
		Category cat = new Category();
		String catName = "01:Crop and animal production, hunting and related service activities";
		cat.setName(catName);
		cat.setModelType(ModelType.PROCESS);
		cat = dao.insert(cat);
		new IsicCategoryTreeSync(database, ModelType.PROCESS).run();
		cat = dao.getForId(cat.getId());
		Assert.assertNotNull(cat.getParentCategory());
		Assert.assertEquals("A:Agriculture, forestry and fishing", cat
				.getParentCategory().getName());
	}

}
{'fraction_non_alphanumeric': 0.1377508935936211, 'fraction_numerical': 0.010998075336816057, 'mean_word_length': 5.4389380530973455, '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': '6817509', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1180, 'n_words': 218}