<commit_before>package com.google.code.maven_replacer_plugin;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

public class XPathReplacerTest {
	private static final int NO_FLAGS = -1;
	
	private Replacement replacement;
	private TokenReplacer tokenReplacer;
	private XPathReplacer replacer;
	
	@Before
	public void setUp() {
		replacement = mock(Replacement.class);
		tokenReplacer = mock(TokenReplacer.class);
		replacer = new XPathReplacer(tokenReplacer);
	}

	@Test
	public void shouldReplaceNonRegexTokenWithValue() throws Exception {
		when(replacement.getXpath()).thenReturn("//test");
		when(replacement.getToken()).thenReturn("token");
		when(replacement.getValue()).thenReturn("value");
		
		when(tokenReplacer.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?><test>token</test>", 
				replacement, false, NO_FLAGS)).thenReturn("<test>value</test>");
		
		String result = replacer.replace("<parent><test>token</test></parent>", replacement, false, NO_FLAGS);
		assertThat(result, containsString("<parent><test>value</test></parent>"));
	}

	@Ignore
	@Test
	public void shouldReplaceRegexTokenWithValue() throws Exception {
		
	}
}<commit_msg>minor cleanup. regex or not does not matter in this test.<commit_after>package com.google.code.maven_replacer_plugin;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

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

public class XPathReplacerTest {
	private static final int NO_FLAGS = -1;
	
	private Replacement replacement;
	private TokenReplacer tokenReplacer;
	private XPathReplacer replacer;
	
	@Before
	public void setUp() {
		replacement = mock(Replacement.class);
		tokenReplacer = mock(TokenReplacer.class);
		replacer = new XPathReplacer(tokenReplacer);
	}

	@Test
	public void shouldReplaceNodeStringLocatedByXpath() throws Exception {
		when(replacement.getXpath()).thenReturn("//test");
		when(replacement.getToken()).thenReturn("token");
		when(replacement.getValue()).thenReturn("value");
		
		when(tokenReplacer.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?><test>token</test>", 
				replacement, false, NO_FLAGS)).thenReturn("<test>value</test>");
		
		String result = replacer.replace("<parent><test>token</test></parent>", replacement, false, NO_FLAGS);
		assertThat(result, containsString("<parent><test>value</test></parent>"));
	}
}
{'fraction_non_alphanumeric': 0.1357750647428783, 'fraction_numerical': 0.0029596744358120607, 'mean_word_length': 6.041666666666667, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 2, '>': 29, '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': '5219598', 'n_tokens_mistral': 886, 'n_tokens_neox': 832, 'n_words': 162}