]> source.dussan.org Git - sonarqube.git/commitdiff
fix some coverage flaws
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 23 Jul 2015 07:33:53 +0000 (09:33 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Thu, 23 Jul 2015 08:30:10 +0000 (10:30 +0200)
server/sonar-server/src/main/java/org/sonar/server/computation/event/Event.java
server/sonar-server/src/main/java/org/sonar/server/computation/qualityprofile/QualityProfile.java
server/sonar-server/src/test/java/org/sonar/server/computation/event/EventTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/qualityprofile/QualityProfileTest.java

index 260be3c0474c54483844a2d3a80a1b064d8fd0fb..e2a977e7d268d19432fa89a8a0bd5e04c54bd397 100644 (file)
@@ -68,7 +68,7 @@ public class Event {
   }
 
   @Override
-  public boolean equals(Object o) {
+  public boolean equals(@Nullable Object o) {
     if (this == o) {
       return true;
     }
index accfd11c1a0ddb833e5b197187899e38d45e74e1..bad693b7006b9abc783440ad27e96fb2cc8ecb6a 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.server.computation.qualityprofile;
 
 import com.google.common.base.Objects;
 import java.util.Date;
+import javax.annotation.Nullable;
 import javax.annotation.concurrent.Immutable;
 
 import static java.util.Objects.requireNonNull;
@@ -60,7 +61,7 @@ public class QualityProfile {
   }
 
   @Override
-  public boolean equals(Object o) {
+  public boolean equals(@Nullable Object o) {
     if (this == o) {
       return true;
     }
@@ -83,7 +84,7 @@ public class QualityProfile {
       .add("key", qpKey)
       .add("name", qpName)
       .add("language", languageKey)
-      .add("rulesUpdatedAt", rulesUpdatedAt)
+      .add("rulesUpdatedAt", rulesUpdatedAt.getTime())
       .toString();
   }
 }
index b3a25ffa67db459ba95ac8fbe44263980a0b0703..92e21eaebf4b58acb1d4fb29dd5adf5a64705be4 100644 (file)
@@ -59,7 +59,9 @@ public class EventTest {
 
   @Test
   public void same_name_and_category_make_equal_events() {
-    assertThat(Event.createAlert(SOME_NAME, null, null)).isEqualTo(Event.createAlert(SOME_NAME, null, null));
-
+    Event source = Event.createAlert(SOME_NAME, null, null);
+    assertThat(source).isEqualTo(Event.createAlert(SOME_NAME, null, null));
+    assertThat(source).isEqualTo(source);
+    assertThat(source).isNotEqualTo(null);
   }
 }
index d4ebfaaa83436d8ac8d965b72f69259d9d12942f..9db6e0f1b47376c1315526c0734fc4d7d1daa06a 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.server.computation.qualityprofile;
 
 import java.util.Date;
 import org.junit.Test;
+import org.sonar.api.utils.DateUtils;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
@@ -29,7 +30,7 @@ public class QualityProfileTest {
   private static final String SOME_QP_KEY = "qpKey";
   private static final String SOME_QP_NAME = "qpName";
   private static final String SOME_LANGUAGE_KEY = "languageKey";
-  private static final Date SOME_DATE = new Date();
+  private static final Date SOME_DATE = DateUtils.parseDateTimeQuietly("2010-05-18T15:50:45+0100");
   private static final QualityProfile QUALITY_PROFILE = new QualityProfile(SOME_QP_KEY, SOME_QP_NAME, SOME_LANGUAGE_KEY, SOME_DATE);
 
   @Test(expected = NullPointerException.class)
@@ -69,4 +70,10 @@ public class QualityProfileTest {
   public void verify_equals() {
     assertThat(QUALITY_PROFILE).isEqualTo(new QualityProfile(SOME_QP_KEY, SOME_QP_NAME, SOME_LANGUAGE_KEY, SOME_DATE));
   }
-}
\ No newline at end of file
+
+  @Test
+  public void verify_toString() {
+    assertThat(QUALITY_PROFILE.toString()).isEqualTo("QualityProfile{key=qpKey, name=qpName, language=languageKey, rulesUpdatedAt=1274194245000}");
+
+  }
+}