<?xml version="1.0" encoding="UTF-8"?>
<test-data>
  <test-code>
    <description>
      <![CDATA[
basic test
      ]]></description>
    <expected-problems>0</expected-problems>
    <code>
      <![CDATA[
public class HelloWorldBean {
  private String _thing;

  public String getMessage() {
    return "Hello World!";
  }
}
      ]]>
    </code>
  </test-code>
  <test-code>
    <description>
      <![CDATA[
basic test, not OK
      ]]></description>
    <expected-problems>1</expected-problems>
    <code>
      <![CDATA[
public class HelloWorldBean {

  public String getMessage() {
    return "Hello World!";
  }
  private String _fieldInWrongLocation;
}
      ]]>
    </code>
  </test-code>
  <test-code>
    <description>
      <![CDATA[
inner class, OK
      ]]></description>
    <expected-problems>0</expected-problems>
    <code>
      <![CDATA[
public class HelloWorldBean {

  public String getMessage() {
    return "Hello World!";
  }

  public class Foo {
    private String _fieldInWrongLocation;
  }
}
      ]]>
    </code>
  </test-code>
  <test-code>
    <description>
      <![CDATA[
Initial report where rule was introduced, [ 2487971 ] False positive with field-level annotations
      ]]></description>
    <expected-problems>0</expected-problems>
    <code>
      <![CDATA[
public class MyTest extends AbstractJUnit4SpringContextTests {
@Autowired
protected String _first;
@Autowired
protected String _second;
}
      ]]>
    </code>
  </test-code>
  <test-code>
    <description>#1126 False positive with FieldDeclarationsShouldBeAtStartOfClass for static enums</description>
    <expected-problems>0</expected-problems>
    <code><![CDATA[
public class Foo {
    private static final Logger LOGGER = LoggerFactory.getLogger(Foo.class);

    public static enum MyType {
        ABC, DEF, GHI, JHK
    };

    private int id;
    private MyType myType;
    private String name;

    // OK, now constructors, getters, setters, etc.
}
    ]]></code>
  </test-code>
  <test-code>
    <description>#1126 Do not ignore enums</description>
    <expected-problems>3</expected-problems>
    <rule-property name="ignoreEnumDeclarations">false</rule-property>
    <code><![CDATA[
public class Foo {
    private static final Logger LOGGER = LoggerFactory.getLogger(Foo.class);

    public static enum MyType {
        ABC, DEF, GHI, JHK
    };

    private int id;
    private MyType myType;
    private String name;

    // OK, now constructors, getters, setters, etc.
}
    ]]></code>
  </test-code>
  <test-code>
    <description>#1244 FieldDeclarationsShouldBeAtStartOfClass and anonymous classes, ok</description>
    <expected-problems>0</expected-problems>
    <code><![CDATA[
public class MyClass {
  private final String name;
  public MyClass() {
      this.name = "whatever";
  }
  public void onCreate() {
     someView.setListener(onSomeViewClick);
  }
  private final OnClickListener onSomeViewClick = new OnClickListener() {
      @Override
      public void onClick(View v) {
          // something
      }
  };
}
    ]]></code>
  </test-code>
  <test-code>
    <description>#1244 FieldDeclarationsShouldBeAtStartOfClass and anonymous classes, fail</description>
    <expected-problems>1</expected-problems>
    <rule-property name="ignoreAnonymousClassDeclarations">false</rule-property>
    <code><![CDATA[
public class MyClass {
  private final String name;
  public MyClass() {
      this.name = "whatever";
  }
  public void onCreate() {
     someView.setListener(onSomeViewClick);
  }
  private final OnClickListener onSomeViewClick = new OnClickListener() {
      @Override
      public void onClick(View v) {
          // something
      }
  };
}
    ]]></code>
  </test-code>
  <test-code>
    <description>#1354 Complex FieldDeclarationsShouldBeAtStartOfClass false positive with Spring annotations</description>
    <expected-problems>0</expected-problems>
    <code><![CDATA[
public class MyClass {
    private static final String MY_STRING = "STRING";

    @Autowired
    private MyPrivate myPrivate;

    @Bean
    public void myPublicBean() {}

    private static void myPrivateStatic() {}
}
    ]]></code>
  </test-code>
  <test-code>
    <description>#1364 FieldDeclarationsShouldBeAtStartOfClass false positive using multiple annotations</description>
    <expected-problems>0</expected-problems>
    <code><![CDATA[
public class MyEntity {

  private static final String MY_STRING = "STRING";

  @Id
  @Column
  private Long id;

  @NotNull
  @ManyToOne
  @JoinColumn
  @Valid
  private RelationEntity relation;

  public MyEntity() {
  }

}
    ]]></code>
  </test-code>
</test-data>