<commit_before>package org.cytoscape.io.internal.write.json;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.cytoscape.io.internal.write.json.serializer.CytoscapeJsNetworkModule;
import org.cytoscape.model.CyNetwork;
import org.junit.Test;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

public class CytoscapeJsViewWriterTest extends AbstractJsonNetworkViewWriterTest {

	@Test
	public void testNetworkViewWriter() throws Exception {

		final ObjectMapper jsMapper = new ObjectMapper();
		jsMapper.registerModule(new CytoscapeJsNetworkModule());

		// Generate file to test site directory.
		File temp = new File("src/test/resources/site/app/data/cytoscapeJsNetwork1.json");

		OutputStream os = new FileOutputStream(temp);
		JSONNetworkViewWriter writer = new JSONNetworkViewWriter(os, view, jsMapper);
		writer.run(tm);

		// Test file contents
		testCytoscapejsFileContent(temp, view.getModel());
	}

	private void testCytoscapejsFileContent(File temp, CyNetwork network) throws Exception {
		// Read contents
		final FileInputStream fileInputStream = new FileInputStream(temp);
		final BufferedReader reader = new BufferedReader(new InputStreamReader(fileInputStream,
				EncodingUtil.getDecoder()));

		final ObjectMapper mapper = new ObjectMapper();
		final JsonNode rootNode = mapper.readValue(reader, JsonNode.class);<commit_msg>Witer test file destination has been changed to target.<commit_after>package org.cytoscape.io.internal.write.json;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.cytoscape.io.internal.write.json.serializer.CytoscapeJsNetworkModule;
import org.cytoscape.model.CyNetwork;
import org.junit.Test;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

public class CytoscapeJsViewWriterTest extends AbstractJsonNetworkViewWriterTest {

	@Test
	public void testNetworkViewWriter() throws Exception {

		final ObjectMapper jsMapper = new ObjectMapper();
		jsMapper.registerModule(new CytoscapeJsNetworkModule());

		// Generate file to test site directory.
		File temp = new File("target/cytoscapeJsNetwork1.json");

		OutputStream os = new FileOutputStream(temp);
		JSONNetworkViewWriter writer = new JSONNetworkViewWriter(os, view, jsMapper);
		writer.run(tm);

		// Test file contents
		testCytoscapejsFileContent(temp, view.getModel());
	}

	private void testCytoscapejsFileContent(File temp, CyNetwork network) throws Exception {
		// Read contents
		final FileInputStream fileInputStream = new FileInputStream(temp);
		final BufferedReader reader = new BufferedReader(new InputStreamReader(fileInputStream,
				EncodingUtil.getDecoder()));

		final ObjectMapper mapper = new ObjectMapper();
		final JsonNode rootNode = mapper.readValue(reader, JsonNode.class);
{'fraction_non_alphanumeric': 0.08930602957906712, 'fraction_numerical': 0.0005688282138794084, 'mean_word_length': 5.992047713717694, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '22256', 'n_tokens_mistral': 1052, 'n_tokens_neox': 971, 'n_words': 237}