test_class.declarator: projectFactory
test_class.modifier: @Inject
     private
test_class.original_string: @Inject
     private ProjectFactory projectFactory;
test_class.type: ProjectFactory
test_class.var_name: projectFactory
test_class.declarator: testHarness
test_class.modifier: @Inject
     private
test_class.original_string: @Inject
     private UITestHarness testHarness;
test_class.type: UITestHarness
test_class.var_name: testHarness
test_class.declarator: facetFactory
test_class.modifier: @Inject
     private
test_class.original_string: @Inject
     private FacetFactory facetFactory;
test_class.type: FacetFactory
test_class.var_name: facetFactory
test_class.declarator: project
test_class.modifier: private
test_class.original_string: private Project project;
test_class.type: Project
test_class.var_name: project
test_class.declarator: targetClass
test_class.modifier: private
test_class.original_string: private JavaClassSource targetClass;
test_class.type: JavaClassSource
test_class.var_name: targetClass
test_class.declarator: commandController
test_class.modifier: private
test_class.original_string: private CommandController commandController;
test_class.type: CommandController
test_class.var_name: commandController
test_class.file: dev-tools-java/src/test/java/org/jboss/forge/addon/devtools/java/JavaEqualsHashcodeCommandTest.java
test_class.identifier: JavaEqualsHashcodeCommandTest
test_case.body: @SuppressWarnings("unchecked")
     @Test
     public void testHashCodeAlreadyInClass() throws Exception
     {
        targetClass = Roaster.parse(JavaClassSource.class, "public class Test{private int id; @Override\n" +
                 "   @Override\n" +
                 "   public int hashCode()\n" +
                 "   {\n" +
                 "      return 1111;\n" +
                 "   }}");
        project.getFacet(JavaSourceFacet.class).saveJavaSource(targetClass);
  
        commandController = testHarness.createCommandController(JavaEqualsHashcodeCommand.class,
                 project.getFacet(JavaSourceFacet.class).getJavaResource(targetClass));
  
        commandController.initialize();
        commandController.setValueFor("targetClass", "Test");
        UISelectMany<String> component = (UISelectMany<String>) commandController.getInputs().get("fields");
        Iterable<String> valueChoices = component.getValueChoices();
        commandController.setValueFor("fields", valueChoices);
        commandController.execute();
        targetClass = Roaster.parse(JavaClassSource.class,
                 project.getFacet(JavaSourceFacet.class).getJavaResource(targetClass)
                          .getUnderlyingResourceObject());
        assertNotNull(targetClass.getField("id"));
        assertTrue(targetClass.getField("id").isPrivate());
        assertNotNull(targetClass.getMethod("equals", Object.class));
        MethodSource<JavaClassSource> hashCodeMethod = targetClass.getMethod("hashCode");
        assertNotNull(hashCodeMethod);
        String body = hashCodeMethod.getBody();
        assertEquals("return 1111;", body);
     }
test_case.class_method_signature: JavaEqualsHashcodeCommandTest.testHashCodeAlreadyInClass()
test_case.full_signature: @SuppressWarnings("unchecked") @Test public void testHashCodeAlreadyInClass()
test_case.identifier: testHashCodeAlreadyInClass
test_case.invocations: parse saveJavaSource getFacet createCommandController getJavaResource getFacet initialize setValueFor get getInputs getValueChoices setValueFor execute parse getUnderlyingResourceObject getJavaResource getFacet assertNotNull getField assertTrue isPrivate getField assertNotNull getMethod getMethod assertNotNull getBody assertEquals
test_case.modifiers: @SuppressWarnings("unchecked") @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testHashCodeAlreadyInClass()
focal_class.declarator: targetClass
focal_class.modifier: private
focal_class.original_string: private UISelectOne<JavaResource> targetClass;
focal_class.type: UISelectOne<JavaResource>
focal_class.var_name: targetClass
focal_class.declarator: fields
focal_class.modifier: private
focal_class.original_string: private UISelectMany<String> fields;
focal_class.type: UISelectMany<String>
focal_class.var_name: fields
focal_class.file: dev-tools-java/src/main/java/org/jboss/forge/addon/devtools/java/JavaEqualsHashcodeCommand.java
focal_class.identifier: JavaEqualsHashcodeCommand
focal_class.class_method_signature: JavaEqualsHashcodeCommand.getMetadata(UIContext context)
focal_class.full_signature: @Override public UICommandMetadata getMetadata(UIContext context)
focal_class.identifier: getMetadata
focal_class.modifiers: @Override public
focal_class.parameters: (UIContext context)
focal_class.return: UICommandMetadata
focal_class.signature: UICommandMetadata getMetadata(UIContext context)
focal_class.class_method_signature: JavaEqualsHashcodeCommand.initializeUI(UIBuilder builder)
focal_class.full_signature: @Override public void initializeUI(UIBuilder builder)
focal_class.identifier: initializeUI
focal_class.modifiers: @Override public
focal_class.parameters: (UIBuilder builder)
focal_class.return: void
focal_class.signature: void initializeUI(UIBuilder builder)
focal_class.class_method_signature: JavaEqualsHashcodeCommand.execute(UIExecutionContext context)
focal_class.full_signature: @Override public Result execute(UIExecutionContext context)
focal_class.identifier: execute
focal_class.modifiers: @Override public
focal_class.parameters: (UIExecutionContext context)
focal_class.return: Result
focal_class.signature: Result execute(UIExecutionContext context)
focal_class.class_method_signature: JavaEqualsHashcodeCommand.setCurrentWorkingResource(UIExecutionContext context, JavaClassSource javaClass)
focal_class.full_signature: private void setCurrentWorkingResource(UIExecutionContext context, JavaClassSource javaClass)
focal_class.identifier: setCurrentWorkingResource
focal_class.modifiers: private
focal_class.parameters: (UIExecutionContext context, JavaClassSource javaClass)
focal_class.return: void
focal_class.signature: void setCurrentWorkingResource(UIExecutionContext context, JavaClassSource javaClass)
focal_class.class_method_signature: JavaEqualsHashcodeCommand.isProjectRequired()
focal_class.full_signature: @Override protected boolean isProjectRequired()
focal_class.identifier: isProjectRequired
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isProjectRequired()
focal_class.class_method_signature: JavaEqualsHashcodeCommand.getProjectFactory()
focal_class.full_signature: @Override protected ProjectFactory getProjectFactory()
focal_class.identifier: getProjectFactory
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: ProjectFactory
focal_class.signature: ProjectFactory getProjectFactory()
focal_class.superclass: extends AbstractProjectCommand
focal_method.body: @Override
     public Result execute(UIExecutionContext context) throws Exception
     {
        JavaResource javaResource = targetClass.getValue();
        JavaClassSource targetClass = javaResource.getJavaType();
        List<FieldSource<JavaClassSource>> selectedFields = new ArrayList<>();
        for (String fieldString : fields.getValue())
        {
           selectedFields.add(targetClass.getField(fieldString));
        }
        UIPrompt prompt = context.getPrompt();
        if (targetClass.hasMethodSignature("equals", Object.class))
        {
           if (prompt.promptBoolean("Class already has an equals method. Would you like it to be overwritten?"))
           {
              Refactory.createEquals(targetClass, selectedFields.toArray(new FieldSource<?>[selectedFields.size()]));
           }
        }
        else
        {
           Refactory.createEquals(targetClass, selectedFields.toArray(new FieldSource<?>[selectedFields.size()]));
        }
        if (targetClass.hasMethodSignature("hashcode"))
        {
           if (prompt.promptBoolean("Class already has a hashcode method. Would you like it to be overwritten?"))
           {
              Refactory.createHashCode(targetClass, selectedFields.toArray(new FieldSource<?>[selectedFields.size()]));
           }
        }
        else
        {
           Refactory.createHashCode(targetClass, selectedFields.toArray(new FieldSource<?>[selectedFields.size()]));
        }
        setCurrentWorkingResource(context, targetClass);
        return Results.success("Command for generation ended successfully");
  
     }
focal_method.class_method_signature: JavaEqualsHashcodeCommand.execute(UIExecutionContext context)
focal_method.full_signature: @Override public Result execute(UIExecutionContext context)
focal_method.identifier: execute
focal_method.invocations: getValue getJavaType getValue add getField getPrompt hasMethodSignature promptBoolean createEquals toArray size createEquals toArray size hasMethodSignature promptBoolean createHashCode toArray size createHashCode toArray size setCurrentWorkingResource success
focal_method.modifiers: @Override public
focal_method.parameters: (UIExecutionContext context)
focal_method.return: Result
focal_method.signature: Result execute(UIExecutionContext context)