// Path: startupheroes-checks/src/test/java/es/startuphero/checkstyle/BaseCheckTestSupport.java
// public abstract class BaseCheckTestSupport extends Assert {
// 
//   private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
// 
//   private final PrintStream printStream = new PrintStream(baos);
// 
//   protected static DefaultConfiguration createCheckConfig(Class<?> clazz) {
//     return new DefaultConfiguration(clazz.getName());
//   }
// 
//   protected static DefaultConfiguration createCheckConfig(Class<?> clazz,
//                                                           Map<String, String> attributeMap) {
//     DefaultConfiguration checkConfig = createCheckConfig(clazz);
//     for (String attributeName : attributeMap.keySet()) {
//       String value = attributeMap.get(attributeName);
//       checkConfig.addAttribute(attributeName, value);
//     }
//     return checkConfig;
//   }
// 
//   protected void verify(Configuration config, String fileName, String[] expected)
//       throws Exception {
//     verify(createChecker(config), fileName, fileName, expected);
//   }
// 
//   protected void verify(Checker c, String fileName, String[] expected) throws Exception {
//     verify(c, fileName, fileName, expected);
//   }
// 
//   private void verify(Checker c, String processedFilename, String messageFileName,
//                       String[] aExpected) throws Exception {
//     verify(c, new File[] {new File(processedFilename)}, messageFileName, aExpected);
//   }
// 
//   private void verify(Checker checker, File[] processedFiles, String messageFileName,
//                       String[] expected) throws Exception {
//     printStream.flush();
//     List<File> testInputFiles = Lists.newArrayList(processedFiles);
//     int foundErrorsCount = checker.process(testInputFiles);
// 
//     // Process each output line
//     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
//     BufferedReader br = new BufferedReader(new InputStreamReader(bais));
// 
//     try {
//       for (int i = 0; i < expected.length; i++) {
//         final String expectedResult = messageFileName + ":" + expected[i];
//         final String actual = br.readLine();
//         assertEquals("error message " + i, expectedResult, actual);
//       }
// 
//       assertEquals("Check generated unexpected warning: " + br.readLine(), expected.length,
//                    foundErrorsCount);
//       checker.destroy();
//     } finally {
//       br.close();
//       bais.close();
//     }
//   }
// 
//   protected Checker createChecker(Configuration checkConfig) throws Exception {
//     Checker checker = new Checker();
//     // make sure the tests always run with english error messages
//     // so the tests don't fail in supported locales like german
//     Locale locale = Locale.ENGLISH;
//     checker.setLocaleCountry(locale.getCountry());
//     checker.setLocaleLanguage(locale.getLanguage());
//     checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader());
// 
//     DefaultConfiguration defaultConfig = createCheckerConfig(checkConfig);
//     checker.configure(defaultConfig);
// 
//     checker.addListener(new BriefLogger(printStream));
//     return checker;
//   }
// 
//   private DefaultConfiguration createCheckerConfig(Configuration config) {
//     DefaultConfiguration result = new DefaultConfiguration("configuration");
//     DefaultConfiguration treeWalkerConfig = createCheckConfig(TreeWalker.class);
//     // make sure that the tests always run with this charset
//     result.addAttribute("charset", "iso-8859-1");
//     result.addChild(treeWalkerConfig);
//     treeWalkerConfig.addChild(config);
//     return result;
//   }
// 
//   protected String getPath(String filename) throws IOException {
//     return (new File("src/test/resources/es/startuphero/checkstyle/" + filename)).getCanonicalPath();
//   }
// 
//   /**
//    * Gets the check message 'as is' from appropriate 'messages.properties' file.
//    *
//    * @param messageKey the key of message in 'messages.properties' file.
//    */
//   protected String getCheckMessage(String messageKey) {
//     Properties pr = new Properties();
//     try {
//       pr.load(getClass().getResourceAsStream("messages.properties"));
//     } catch (IOException e) {
//       return null;
//     }
//     return pr.getProperty(messageKey);
//   }
// 
//   /**
//    * Gets the check message 'as is' from appropriate 'messages.properties' file.
//    *
//    * @param messageKey the key of message in 'messages.properties' file.
//    * @param arguments the arguments of message in 'messages.properties' file.
//    */
//   protected String getCheckMessage(String messageKey, Object... arguments) {
//     return format(getCheckMessage(messageKey), arguments);
//   }
// 
//   protected List<File> prepareFilesToBeChecked(String fileName) {
//     URL testFileUrl = getClass().getResource(fileName);
//     File testFile = new File(testFileUrl.getFile());
//     List<File> files = new ArrayList<File>();
//     files.add(testFile);
//     return files;
//   }
// 
//   /** A brief logger that only display errors */
//   private static class BriefLogger extends DefaultLogger {
// 
//     BriefLogger(OutputStream out) {
//       super(out, OutputStreamOptions.CLOSE, out, OutputStreamOptions.NONE, new AuditEventUtFormatter());
//     }
// 
//     @Override
//     public void auditStarted(AuditEvent evt) {
//     }
// 
//     @Override
//     public void fileFinished(AuditEvent evt) {
//     }
// 
//     @Override
//     public void fileStarted(AuditEvent evt) {
//     }
//   }
// }


import com.google.common.collect.ImmutableMap;
import es.startuphero.checkstyle.BaseCheckTestSupport;
import java.io.File;
import java.io.IOException;
import org.junit.Test;
package es.startuphero.checkstyle.checks.annotation;


/**
 * @author ozlem.ulag
 */
public class RedundantMultipleAnnotationCheckTest extends BaseCheckTestSupport {

  private static final String MSG_KEY = "redundant.multiple.annotation";

  @Test
  public void testByWrongInput() throws Exception {
    String[] expectedMessages = {"28: " + getCheckMessage(MSG_KEY, "Id", "Column")};
    test("TestWrongEntity.java", expectedMessages);
  }

  @Test
  public void testByCorrectInput() throws Exception {
    String[] expectedMessages = {};
    test("TestCorrectEntity.java", expectedMessages);
  }

// Path: startupheroes-checks/src/test/java/es/startuphero/checkstyle/BaseCheckTestSupport.java
// public abstract class BaseCheckTestSupport extends Assert {
// 
//   private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
// 
//   private final PrintStream printStream = new PrintStream(baos);
// 
//   protected static DefaultConfiguration createCheckConfig(Class<?> clazz) {
//     return new DefaultConfiguration(clazz.getName());
//   }
// 
//   protected static DefaultConfiguration createCheckConfig(Class<?> clazz,
//                                                           Map<String, String> attributeMap) {
//     DefaultConfiguration checkConfig = createCheckConfig(clazz);
//     for (String attributeName : attributeMap.keySet()) {
//       String value = attributeMap.get(attributeName);
//       checkConfig.addAttribute(attributeName, value);
//     }
//     return checkConfig;
//   }
// 
//   protected void verify(Configuration config, String fileName, String[] expected)
//       throws Exception {
//     verify(createChecker(config), fileName, fileName, expected);
//   }
// 
//   protected void verify(Checker c, String fileName, String[] expected) throws Exception {
//     verify(c, fileName, fileName, expected);
//   }
// 
//   private void verify(Checker c, String processedFilename, String messageFileName,
//                       String[] aExpected) throws Exception {
//     verify(c, new File[] {new File(processedFilename)}, messageFileName, aExpected);
//   }
// 
//   private void verify(Checker checker, File[] processedFiles, String messageFileName,
//                       String[] expected) throws Exception {
//     printStream.flush();
//     List<File> testInputFiles = Lists.newArrayList(processedFiles);
//     int foundErrorsCount = checker.process(testInputFiles);
// 
//     // Process each output line
//     ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
//     BufferedReader br = new BufferedReader(new InputStreamReader(bais));
// 
//     try {
//       for (int i = 0; i < expected.length; i++) {
//         final String expectedResult = messageFileName + ":" + expected[i];
//         final String actual = br.readLine();
//         assertEquals("error message " + i, expectedResult, actual);
//       }
// 
//       assertEquals("Check generated unexpected warning: " + br.readLine(), expected.length,
//                    foundErrorsCount);
//       checker.destroy();
//     } finally {
//       br.close();
//       bais.close();
//     }
//   }
// 
//   protected Checker createChecker(Configuration checkConfig) throws Exception {
//     Checker checker = new Checker();
//     // make sure the tests always run with english error messages
//     // so the tests don't fail in supported locales like german
//     Locale locale = Locale.ENGLISH;
//     checker.setLocaleCountry(locale.getCountry());
//     checker.setLocaleLanguage(locale.getLanguage());
//     checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader());
// 
//     DefaultConfiguration defaultConfig = createCheckerConfig(checkConfig);
//     checker.configure(defaultConfig);
// 
//     checker.addListener(new BriefLogger(printStream));
//     return checker;
//   }
// 
//   private DefaultConfiguration createCheckerConfig(Configuration config) {
//     DefaultConfiguration result = new DefaultConfiguration("configuration");
//     DefaultConfiguration treeWalkerConfig = createCheckConfig(TreeWalker.class);
//     // make sure that the tests always run with this charset
//     result.addAttribute("charset", "iso-8859-1");
//     result.addChild(treeWalkerConfig);
//     treeWalkerConfig.addChild(config);
//     return result;
//   }
// 
//   protected String getPath(String filename) throws IOException {
//     return (new File("src/test/resources/es/startuphero/checkstyle/" + filename)).getCanonicalPath();
//   }
// 
//   /**
//    * Gets the check message 'as is' from appropriate 'messages.properties' file.
//    *
//    * @param messageKey the key of message in 'messages.properties' file.
//    */
//   protected String getCheckMessage(String messageKey) {
//     Properties pr = new Properties();
//     try {
//       pr.load(getClass().getResourceAsStream("messages.properties"));
//     } catch (IOException e) {
//       return null;
//     }
//     return pr.getProperty(messageKey);
//   }
// 
//   /**
//    * Gets the check message 'as is' from appropriate 'messages.properties' file.
//    *
//    * @param messageKey the key of message in 'messages.properties' file.
//    * @param arguments the arguments of message in 'messages.properties' file.
//    */
//   protected String getCheckMessage(String messageKey, Object... arguments) {
//     return format(getCheckMessage(messageKey), arguments);
//   }
// 
//   protected List<File> prepareFilesToBeChecked(String fileName) {
//     URL testFileUrl = getClass().getResource(fileName);
//     File testFile = new File(testFileUrl.getFile());
//     List<File> files = new ArrayList<File>();
//     files.add(testFile);
//     return files;
//   }
// 
//   /** A brief logger that only display errors */
//   private static class BriefLogger extends DefaultLogger {
// 
//     BriefLogger(OutputStream out) {
//       super(out, OutputStreamOptions.CLOSE, out, OutputStreamOptions.NONE, new AuditEventUtFormatter());
//     }
// 
//     @Override
//     public void auditStarted(AuditEvent evt) {
//     }
// 
//     @Override
//     public void fileFinished(AuditEvent evt) {
//     }
// 
//     @Override
//     public void fileStarted(AuditEvent evt) {
//     }
//   }
// }


// Path: startupheroes-checks/src/test/java/es/startuphero/checkstyle/checks/annotation/RedundantMultipleAnnotationCheckTest.java
import com.google.common.collect.ImmutableMap;
import es.startuphero.checkstyle.BaseCheckTestSupport;
import java.io.File;
import java.io.IOException;
import org.junit.Test;

package es.startuphero.checkstyle.checks.annotation;


/**
 * @author ozlem.ulag
 */
public class RedundantMultipleAnnotationCheckTest extends BaseCheckTestSupport {

  private static final String MSG_KEY = "redundant.multiple.annotation";

  @Test
  public void testByWrongInput() throws Exception {
    String[] expectedMessages = {"28: " + getCheckMessage(MSG_KEY, "Id", "Column")};
    test("TestWrongEntity.java", expectedMessages);
  }

  @Test
  public void testByCorrectInput() throws Exception {
    String[] expectedMessages = {};
    test("TestCorrectEntity.java", expectedMessages);
  }

  private void test(String fileName, String[] expectedMessages) throws Exception {