<commit_before>package com.matthewtamlin.spyglass.processor.code_generation.get_placeholder_method_generator;

import com.matthewtamlin.avatar.rules.AvatarRule;
import com.matthewtamlin.spyglass.processor.annotation_retrievers.UseAnnoRetriever;
import com.matthewtamlin.spyglass.processor.code_generation.CallerDef;
import com.matthewtamlin.spyglass.processor.code_generation.GetPlaceholderMethodGenerator;
import com.matthewtamlin.spyglass.processor.core.CoreHelpers;
import com.matthewtamlin.spyglass.processor.framework.CompileChecker;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;

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

import java.util.HashSet;
import java.util.Set;

import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.VariableElement;

import static javax.lang.model.element.Modifier.STATIC;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.mockito.Mockito.mock;

public class TestGetPlaceholderMethodGenerator {
	@Rule
	public final AvatarRule avatarRule = AvatarRule
			.builder()
			.withSourcesAt("processor/src/test/java/com/matthewtamlin/spyglass/processor/code_generation/" +
					"get_placeholder_method_generator/Data.java")
			.build();

	private GetPlaceholderMethodGenerator generator;

	@Before
	public void setup() {
		final CoreHelpers coreHelpers = new CoreHelpers(avatarRule.getElementUtils(), avatarRule.getTypeUtils());
		generator = new GetPlaceholderMethodGenerator(coreHelpers);
	}

	@Test(expected = IllegalArgumentException.class)
	public void testConstructor_nullCoreHelpers() {
		new GetPlaceholderMethodGenerator(null);
	}

	@Test(expected = IllegalArgumentException.class)
	public void testGenerateFor_nullParameter() {
		generator.generateFor(null, 0);
	}

	@Test(expected = IllegalArgumentException.class)
	public void testGenerateFor_negativeParameterIndex() {
		final VariableElement parameter = avatarRule.getElementWithUniqueId("boolean");
		final AnnotationMirror useAnnotation = UseAnnoRetriever.getAnnotation(parameter);

		generator.generateFor(useAnnotation, -1);
	}

	@Test
	public void testGenerateFor_zeroParameterIndex() {
		final VariableElement parameter = avatarRule.getElementWithUniqueId("boolean");
		final AnnotationMirror useAnnotation = UseAnnoRetriever.getAnnotation(parameter);

		generator.generateFor(useAnnotation, 0);
	}

	@Test
	public void testGenerateFor_positiveParameterIndex() {
		final VariableElement parameter = avatarRule.getElementWithUniqueId("boolean");
		final AnnotationMirror useAnnotation = UseAnnoRetriever.getAnnotation(parameter);

		generator.generateFor(useAnnotation, 1);
	}

	@Test
	public void testGenerateFor_parameterWithUseBoolean() {
		final VariableElement parameter = avatarRule.getElementWithUniqueId("boolean");
		final AnnotationMirror useAnnotation = UseAnnoRetriever.getAnnotation(parameter);

		final MethodSpec generatedMethod = generator.generateFor(useAnnotation, 0);

		checkSignature(generatedMethod, ClassName.get(Boolean.class));
		checkCompiles(generatedMethod);
	}

	@Test
	public void testGenerateFor_parameterWithUseByte() {
		final VariableElement parameter = avatarRule.getElementWithUniqueId("byte");
		final AnnotationMirror useAnnotation = UseAnnoRetriever.getAnnotation(parameter);

		final MethodSpec generatedMethod = generator.generateFor(useAnnotation, 0);

		checkSignature(generatedMethod, ClassName.get(Number.class));
		checkCompiles(generatedMethod);
	}

	@Test
	public void testGenerateFor_parameterWithUseChar() {
		final VariableElement parameter = avatarRule.getElementWithUniqueId("char");
		final AnnotationMirror useAnnotation = UseAnnoRetriever.getAnnotation(parameter);

		final MethodSpec generatedMethod = generator.generateFor(useAnnotation, 0);

		checkSignature(generatedMethod, ClassName.get(Number.class));
		checkCompiles(generatedMethod);
	}

	@Test
	public void testGenerateFor_parameterWithUseDouble() {
		final VariableElement parameter = avatarRule.getElementWithUniqueId("double");
		final AnnotationMirror useAnnotation = UseAnnoRetriever.getAnnotation(parameter);

		final MethodSpec generatedMethod = generator.generateFor(useAnnotation, 0);
<commit_msg>test(processor): updated expected return type<commit_after>package com.matthewtamlin.spyglass.processor.code_generation.get_placeholder_method_generator;

import com.matthewtamlin.avatar.rules.AvatarRule;
import com.matthewtamlin.spyglass.processor.annotation_retrievers.UseAnnoRetriever;
import com.matthewtamlin.spyglass.processor.code_generation.CallerDef;
import com.matthewtamlin.spyglass.processor.code_generation.GetPlaceholderMethodGenerator;
import com.matthewtamlin.spyglass.processor.core.CoreHelpers;
import com.matthewtamlin.spyglass.processor.framework.CompileChecker;
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.JavaFile;
import com.squareup.javapoet.MethodSpec;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;

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

import java.util.HashSet;
import java.util.Set;

import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.VariableElement;

import static javax.lang.model.element.Modifier.STATIC;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.mockito.Mockito.mock;

public class TestGetPlaceholderMethodGenerator {
	@Rule
	public final AvatarRule avatarRule = AvatarRule
			.builder()
			.withSourcesAt("processor/src/test/java/com/matthewtamlin/spyglass/processor/code_generation/" +
					"get_placeholder_method_generator/Data.java")
			.build();

	private GetPlaceholderMethodGenerator generator;

	@Before
	public void setup() {
		final CoreHelpers coreHelpers = new CoreHelpers(avatarRule.getElementUtils(), avatarRule.getTypeUtils());
		generator = new GetPlaceholderMethodGenerator(coreHelpers);
	}

	@Test(expected = IllegalArgumentException.class)
	public void testConstructor_nullCoreHelpers() {
		new GetPlaceholderMethodGenerator(null);
	}

	@Test(expected = IllegalArgumentException.class)
	public void testGenerateFor_nullParameter() {
		generator.generateFor(null, 0);
	}

	@Test(expected = IllegalArgumentException.class)
	public void testGenerateFor_negativeParameterIndex() {
		final VariableElement parameter = avatarRule.getElementWithUniqueId("boolean");
		final AnnotationMirror useAnnotation = UseAnnoRetriever.getAnnotation(parameter);

		generator.generateFor(useAnnotation, -1);
	}

	@Test
	public void testGenerateFor_zeroParameterIndex() {
		final VariableElement parameter = avatarRule.getElementWithUniqueId("boolean");
		final AnnotationMirror useAnnotation = UseAnnoRetriever.getAnnotation(parameter);

		generator.generateFor(useAnnotation, 0);
	}

	@Test
	public void testGenerateFor_positiveParameterIndex() {
		final VariableElement parameter = avatarRule.getElementWithUniqueId("boolean");
		final AnnotationMirror useAnnotation = UseAnnoRetriever.getAnnotation(parameter);

		generator.generateFor(useAnnotation, 1);
	}

	@Test
	public void testGenerateFor_parameterWithUseBoolean() {
		final VariableElement parameter = avatarRule.getElementWithUniqueId("boolean");
		final AnnotationMirror useAnnotation = UseAnnoRetriever.getAnnotation(parameter);

		final MethodSpec generatedMethod = generator.generateFor(useAnnotation, 0);

		checkSignature(generatedMethod, ClassName.get(Boolean.class));
		checkCompiles(generatedMethod);
	}

	@Test
	public void testGenerateFor_parameterWithUseByte() {
		final VariableElement parameter = avatarRule.getElementWithUniqueId("byte");
		final AnnotationMirror useAnnotation = UseAnnoRetriever.getAnnotation(parameter);

		final MethodSpec generatedMethod = generator.generateFor(useAnnotation, 0);

		checkSignature(generatedMethod, ClassName.get(Number.class));
		checkCompiles(generatedMethod);
	}

	@Test
	public void testGenerateFor_parameterWithUseChar() {
		final VariableElement parameter = avatarRule.getElementWithUniqueId("char");
		final AnnotationMirror useAnnotation = UseAnnoRetriever.getAnnotation(parameter);

		final MethodSpec generatedMethod = generator.generateFor(useAnnotation, 0);

		checkSignature(generatedMethod, ClassName.get(Character.class));
		checkCompiles(generatedMethod);
	}

	@Test
	public void testGenerateFor_parameterWithUseDouble() {
		final VariableElement parameter = avatarRule.getElementWithUniqueId("double");
		final AnnotationMirror useAnnotation = UseAnnoRetriever.getAnnotation(parameter);

		final MethodSpec generatedMethod = generator.generateFor(useAnnotation, 0);

{'fraction_non_alphanumeric': 0.08652227583885086, 'fraction_numerical': 0.001795533610144765, 'mean_word_length': 7.368075117370892, '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': '3530026', 'n_tokens_mistral': 2674, 'n_tokens_neox': 2467, 'n_words': 436}