Commit 18f22bf7cdf6c95aa0d0b56fe28e41dc5fa46726

Authored by rodrigo.lima
1 parent 6d19411d

git-svn-id: https://svn.bento.ifrs.edu.br/default/ASES/ASES%20-%20Web/ASES%20-%2…

…0Web/Fontes/avaliador-api@10134 c2178572-b5ca-4887-91d2-9e3a90c7d55b
src/main/java/br/com/checker/emag/Occurrence.java
... ... @@ -4,7 +4,7 @@ import lombok.Getter;
4 4 import lombok.ToString;
5 5  
6 6 @ToString
7   -public @Getter class Occurrence {
  7 +public @Getter class Occurrence implements Comparable<Occurrence>{
8 8  
9 9 private Integer line;
10 10 private Integer column;
... ... @@ -59,5 +59,46 @@ public @Getter class Occurrence {
59 59 this.tag = this.tag.replaceAll(" ", "&nbsp");
60 60 return tag;
61 61 }
  62 +
  63 +
  64 + @Override
  65 + public int hashCode() {
  66 + final int prime = 31;
  67 + int result = 1;
  68 + result = prime * result + ((code == null) ? 0 : code.hashCode());
  69 + result = prime * result + ((line == null) ? 0 : line.hashCode());
  70 + return result;
  71 + }
  72 +
  73 +
  74 + @Override
  75 + public boolean equals(Object obj) {
  76 + if (this == obj)
  77 + return true;
  78 + if (obj == null)
  79 + return false;
  80 + if (getClass() != obj.getClass())
  81 + return false;
  82 + Occurrence other = (Occurrence) obj;
  83 + if (code == null) {
  84 + if (other.code != null)
  85 + return false;
  86 + } else if (!code.equals(other.code))
  87 + return false;
  88 + if (line == null) {
  89 + if (other.line != null)
  90 + return false;
  91 + } else if (!line.equals(other.line))
  92 + return false;
  93 + return true;
  94 + }
  95 +
  96 +
  97 + public int compareTo(Occurrence other) {
  98 +
  99 + return this.line.compareTo(other.line);
  100 + }
  101 +
  102 +
62 103  
63 104 }
... ...
src/main/java/br/com/checker/emag/core/BehaviorEvaluation.java
... ... @@ -25,6 +25,7 @@ public class BehaviorEvaluation extends Evaluation{
25 25 public SpecificRecommendation recommendation13() { return new EvaluationRecommendation13();}
26 26 public SpecificRecommendation recommendation14() { return new EvaluationRecommendation14();}
27 27 public SpecificRecommendation recommendation15() { return new EvaluationRecommendation15();}
  28 + public SpecificRecommendation recommendation16() { return new EvaluationRecommendation16();}
28 29 }
29 30  
30 31 protected static class EvaluationRecommendation10 extends BehaviorRecommendation{
... ... @@ -249,7 +250,7 @@ List&lt;Occurrence&gt; occurrences = new ArrayList&lt;Occurrence&gt;();
249 250  
250 251 private List<Occurrence> checkRecommendation16() {
251 252 List<Occurrence> occurrences = new ArrayList<Occurrence>();
252   - occurrences.add(new Occurrence("2.7", false, getDocument().getFirstElement().toString(),OccurrenceClassification.CONTENT_INFORMATION));
  253 + occurrences.add(new Occurrence("2.7", false, getDocument().getFirstElement().toString(),OccurrenceClassification.BEHAVIOR));
253 254 return occurrences;
254 255 }
255 256  
... ...
src/test/java/br/com/checker/emag/ContentEvaluationTest.java
... ... @@ -16,20 +16,6 @@ import org.junit.runners.JUnit4;
16 16 @RunWith(JUnit4.class)
17 17 public class ContentEvaluationTest {
18 18  
19   - @Test
20   - public void shouldCheckRecommedation16() {
21   -
22   - StringBuilder html = new StringBuilder("<html> ");
23   - html.append("</html>");
24   -
25   - Map<OccurrenceClassification,List<Occurrence>> occurrences = from(html.toString())
26   - .with(content().recommendation16()).check();
27   -
28   - assertEquals("Should return 1 occurrences", 1,occurrences.get(OccurrenceClassification.CONTENT_INFORMATION).size());
29   - assertEquals("Should return Recommendation 16","2.7",occurrences.get(OccurrenceClassification.CONTENT_INFORMATION).get(0).getCode());
30   - assertFalse("Recommendation 17 should be ERROR",occurrences.get(OccurrenceClassification.CONTENT_INFORMATION).get(0).isError());
31   - }
32   -
33 19  
34 20 @Test
35 21 public void shouldCheckRecommedation17() {
... ...