<commit_before>package org.jrobin.cmd;

import java.io.IOException;

import org.jrobin.core.RrdDb;
import org.jrobin.core.RrdDef;
import org.jrobin.core.RrdException;
import org.jrobin.core.jrrd.RRDException;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;

public class RrdGraphCmdTest {

	RrdGraphCmd graphCmd;
	String jrbFileName;

	@Before
	public void setUp() throws RrdException, IOException {
		Assume.assumeTrue(!Boolean.getBoolean("java.awt.headless"));

		// Don't use stdout; this silences output if we're outputting to "-"
		// If debugging, you may wish to turn this to true, in case there's
		// output that is helpful in figuring
		// But, note that then you'll get the GIF file printed to stdout as well
		RrdToolCmd.setStandardOutUsed(false);

		// Create a simple JRB file called test-graph-cmd with an RRA called
		// "testvalue" (AVERAGE). Enough to generate graphs using RrdGraphCmd.
		// Note we're not testing the graphing itself, just the parsing
		this.jrbFileName = "target/test-graph-cmd.jrb";
		RrdDef def = new RrdDef(this.jrbFileName);
		def.setStartTime(1000);
		def.setStep(1);
		def.addDatasource("testvalue", "GAUGE", 2, Double.NaN, Double.NaN);
		def.addArchive("RRA:AVERAGE:0.5:1:100");
		RrdDb rrd = new RrdDb(def);
		rrd.close();

		this.graphCmd = new RrdGraphCmd();

	}

	@Test
	/*1
	 * There was a null pointer exception lurking in the code that parses the
	 * AREA statement, if there is no legend.
	 */
	public void testBasicGraph() throws RrdException, IOException, RRDException {
		this.graphCmd.executeCommand("graph - DEF:testvalue="
				+ this.jrbFileName
				+ ":testvalue:AVERAGE AREA:testvalue#FF0000:TestValue");
	}

	@Test
	/*
	 * There was a null pointer exception lurking in the code that parses the
	 * AREA statement, if there was no legend.
	 */
	public void testAreaWithoutLegend() throws RrdException, IOException,
			RRDException {
		// The command we execute is necessarily quite short, but should still<commit_msg>only run tests if we can careate the RrdGraphCmd object<commit_after>package org.jrobin.cmd;

import java.io.IOException;

import org.jrobin.core.RrdDb;
import org.jrobin.core.RrdDef;
import org.jrobin.core.RrdException;
import org.jrobin.core.jrrd.RRDException;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;

public class RrdGraphCmdTest {

	RrdGraphCmd graphCmd;
	String jrbFileName;

	@Before
	public void setUp() throws RrdException, IOException {
		// Don't use stdout; this silences output if we're outputting to "-"
		// If debugging, you may wish to turn this to true, in case there's
		// output that is helpful in figuring
		// But, note that then you'll get the GIF file printed to stdout as well
		RrdToolCmd.setStandardOutUsed(false);

		// Create a simple JRB file called test-graph-cmd with an RRA called
		// "testvalue" (AVERAGE). Enough to generate graphs using RrdGraphCmd.
		// Note we're not testing the graphing itself, just the parsing
		this.jrbFileName = "target/test-graph-cmd.jrb";
		RrdDef def = new RrdDef(this.jrbFileName);
		def.setStartTime(1000);
		def.setStep(1);
		def.addDatasource("testvalue", "GAUGE", 2, Double.NaN, Double.NaN);
		def.addArchive("RRA:AVERAGE:0.5:1:100");
		RrdDb rrd = new RrdDb(def);
		rrd.close();

		try {
			this.graphCmd = new RrdGraphCmd();
		} catch (final Exception e) {
			System.err.println("unable to create RrdGraphCmd object!");
			e.printStackTrace();
		}
		
		Assume.assumeNotNull(this.graphCmd);
	}

	@Test
	/*1
	 * There was a null pointer exception lurking in the code that parses the
	 * AREA statement, if there is no legend.
	 */
	public void testBasicGraph() throws RrdException, IOException, RRDException {
		this.graphCmd.executeCommand("graph - DEF:testvalue="
				+ this.jrbFileName
				+ ":testvalue:AVERAGE AREA:testvalue#FF0000:TestValue");
	}

	@Test
	/*
	 * There was a null pointer exception lurking in the code that parses the
	 * AREA statement, if there was no legend.
	 */
	public void testAreaWithoutLegend() throws RrdException, IOException,
			RRDException {
		// The command we execute is necessarily quite short, but should still
{'fraction_non_alphanumeric': 0.1022864019253911, 'fraction_numerical': 0.008182912154031288, 'mean_word_length': 4.080684596577017, 'pattern_counts': {'":': 2, '<': 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': '2544997', 'n_tokens_mistral': 1473, 'n_tokens_neox': 1339, 'n_words': 421}