aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-06-15 16:44:01 +0200
committerDavid Gageot <david@gageot.net>2012-06-15 16:44:01 +0200
commitbe33ec41314feb7b5dea29d56b9855a03455e45a (patch)
treea1e9c4e219bc3edd5cd15fd934c3d6ac965515af /sonar-plugin-api
parent0f580d01542078b59532642add4a0aba7651c79e (diff)
downloadsonarqube-be33ec41314feb7b5dea29d56b9855a03455e45a.tar.gz
sonarqube-be33ec41314feb7b5dea29d56b9855a03455e45a.zip
Remove violations
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/measures/RangeDistributionBuilderTest.java58
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/platform/ComponentContainerTest.java40
2 files changed, 48 insertions, 50 deletions
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/RangeDistributionBuilderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/RangeDistributionBuilderTest.java
index 334ddfc5ff8..c54e8e2cf7f 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/RangeDistributionBuilderTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/RangeDistributionBuilderTest.java
@@ -21,58 +21,58 @@ package org.sonar.api.measures;
import org.junit.Test;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class RangeDistributionBuilderTest {
-
+
@Test
public void workOnAnLimitsArrayCopy() {
- Integer[] limits = new Integer[]{4,2,0};
+ Integer[] limits = new Integer[] {4, 2, 0};
RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, limits);
builder.add(3.2).add(2.0).add(6.2).build();
- assertTrue(builder.getBottomLimits() != limits);
- assertThat(limits[0], is(4));
- assertThat(limits[1], is(2));
- assertThat(limits[2], is(0));
+
+ assertThat(builder.getBottomLimits()).isNotSameAs(limits);
+ assertThat(limits[0]).isEqualTo(4);
+ assertThat(limits[1]).isEqualTo(2);
+ assertThat(limits[2]).isEqualTo(0);
}
@Test
public void buildIntegerDistribution() {
- RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, new Integer[]{0, 2, 4});
+ RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, new Integer[] {0, 2, 4});
Measure measure = builder
.add(3.2)
.add(2.0)
.add(6.2)
.build();
- assertThat(measure.getData(), is("0=0;2=2;4=1"));
+ assertThat(measure.getData()).isEqualTo("0=0;2=2;4=1");
}
@Test
public void buildDoubleDistribution() {
- RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, new Double[]{0.0, 2.0, 4.0});
+ RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, new Double[] {0.0, 2.0, 4.0});
Measure measure = builder
.add(3.2)
.add(2.0)
.add(6.2)
.build();
- assertThat(measure.getData(), is("0=0;2=2;4=1"));
+ assertThat(measure.getData()).isEqualTo("0=0;2=2;4=1");
}
@Test
public void valueLesserThanMinimumIsIgnored() {
- RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, new Integer[]{0, 2, 4});
+ RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, new Integer[] {0, 2, 4});
Measure measure = builder
.add(3.2)
.add(2.0)
.add(-3.0)
.build();
- assertThat(measure.getData(), is("0=0;2=2;4=0"));
+ assertThat(measure.getData()).isEqualTo("0=0;2=2;4=0");
}
@Test
@@ -80,30 +80,29 @@ public class RangeDistributionBuilderTest {
Measure measureToAdd = mock(Measure.class);
when(measureToAdd.getData()).thenReturn("0=3;2=5");
- RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, new Integer[]{0, 2});
+ RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, new Integer[] {0, 2});
builder.clear();
Measure measure = builder
.add(1)
.add(measureToAdd)
.build();
- assertThat(measure.getData(), is("0=4;2=5"));
+ assertThat(measure.getData()).isEqualTo("0=4;2=5");
}
-
@Test
public void addDistributionMeasureWithDifferentIntLimits() {
Measure measureToAdd = mock(Measure.class);
when(measureToAdd.getData()).thenReturn("0=3;2=5");
- RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, new Integer[]{0, 2, 4});
+ RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, new Integer[] {0, 2, 4});
builder.clear();
Measure measure = builder
.add(1)
.add(measureToAdd)
.build();
- assertNull(measure);
+ assertThat(measure).isNull();
}
@Test
@@ -111,13 +110,13 @@ public class RangeDistributionBuilderTest {
Measure measureToAdd = mock(Measure.class);
when(measureToAdd.getData()).thenReturn("0.0=3;3.0=5;6.0=9");
- RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, new Double[]{0.0, 2.0, 4.0});
+ RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, new Double[] {0.0, 2.0, 4.0});
builder.clear();
Measure measure = builder
.add(measureToAdd)
.build();
- assertNull(measure);
+ assertThat(measure).isNull();
}
@Test
@@ -135,10 +134,9 @@ public class RangeDistributionBuilderTest {
.add(m2)
.build();
- assertThat(measure.getData(), is("0.5=3;3.5=7;6.5=10"));
+ assertThat(measure.getData()).isEqualTo("0.5=3;3.5=7;6.5=10");
}
-
@Test
public void keepIntRangesWhenMergingDistributions() {
Measure m1 = mock(Measure.class);
@@ -154,26 +152,26 @@ public class RangeDistributionBuilderTest {
.add(m2)
.build();
- assertThat(measure.getData(), is("0=3;3=7;6=10"));
+ assertThat(measure.getData()).isEqualTo("0=3;3=7;6=10");
}
@Test
public void nullIfEmptyData() {
- RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, new Integer[]{0, 2, 4});
+ RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.CLASS_COMPLEXITY_DISTRIBUTION, new Integer[] {0, 2, 4});
- assertThat(builder.isEmpty(), is(true));
+ assertThat(builder.isEmpty()).isTrue();
Measure measure = builder.build(false);
- assertNull(measure);
+ assertThat(measure).isNull();
measure = builder.build(true);
- assertThat(measure.getData(), is("0=0;2=0;4=0"));
+ assertThat(measure.getData()).isEqualTo("0=0;2=0;4=0");
}
@Test
public void aggregateEmptyDistribution() {
RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.LCOM4_DISTRIBUTION);
- builder.add(new Measure(CoreMetrics.LCOM4_DISTRIBUTION, (String)null));
+ builder.add(new Measure(CoreMetrics.LCOM4_DISTRIBUTION, (String) null));
Measure distribution = builder.build();
- assertThat(distribution.getData(), is(""));
+ assertThat(distribution.getData()).isEmpty();
}
}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/platform/ComponentContainerTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/platform/ComponentContainerTest.java
index db6f03b1106..0c3a8293b03 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/platform/ComponentContainerTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/platform/ComponentContainerTest.java
@@ -24,8 +24,7 @@ import org.sonar.api.Property;
import org.sonar.api.config.PropertyDefinitions;
import static junit.framework.Assert.assertTrue;
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.mock;
public class ComponentContainerTest {
@@ -33,7 +32,8 @@ public class ComponentContainerTest {
@Test
public void shouldRegisterItself() {
ComponentContainer container = new ComponentContainer();
- assertTrue(container.getComponentByType(ComponentContainer.class) == container);
+
+ assertThat(container.getComponentByType(ComponentContainer.class)).isSameAs(container);
}
@Test
@@ -42,11 +42,11 @@ public class ComponentContainerTest {
container.addSingleton(StartableComponent.class);
container.startComponents();
- assertThat(container.getComponentByType(StartableComponent.class).started, is(true));
- assertThat(container.getComponentByType(StartableComponent.class).stopped, is(false));
+ assertThat(container.getComponentByType(StartableComponent.class).started).isTrue();
+ assertThat(container.getComponentByType(StartableComponent.class).stopped).isFalse();
container.stopComponents();
- assertThat(container.getComponentByType(StartableComponent.class).stopped, is(true));
+ assertThat(container.getComponentByType(StartableComponent.class).stopped).isTrue();
}
@Test
@@ -58,12 +58,12 @@ public class ComponentContainerTest {
child.addSingleton(StartableComponent.class);
child.startComponents();
- assertTrue(child.getParent() == parent);
- assertTrue(parent.getChild() == child);
- assertTrue(child.getComponentByType(ComponentContainer.class) == child);
- assertTrue(parent.getComponentByType(ComponentContainer.class) == parent);
- assertThat(child.getComponentByType(StartableComponent.class), notNullValue());
- assertThat(parent.getComponentByType(StartableComponent.class), nullValue());
+ assertThat(child.getParent()).isSameAs(parent);
+ assertThat(parent.getChild()).isSameAs(child);
+ assertThat(child.getComponentByType(ComponentContainer.class)).isSameAs(child);
+ assertThat(parent.getComponentByType(ComponentContainer.class)).isSameAs(parent);
+ assertThat(child.getComponentByType(StartableComponent.class)).isNotNull();
+ assertThat(parent.getComponentByType(StartableComponent.class)).isNull();
parent.stopComponents();
}
@@ -74,10 +74,10 @@ public class ComponentContainerTest {
parent.startComponents();
ComponentContainer child = parent.createChild();
- assertTrue(parent.getChild() == child);
+ assertThat(parent.getChild()).isSameAs(child);
parent.removeChild();
- assertThat(parent.getChild(), nullValue());
+ assertThat(parent.getChild()).isNull();
}
@Test
@@ -102,8 +102,8 @@ public class ComponentContainerTest {
container.addSingleton(ComponentWithProperty.class);
PropertyDefinitions propertyDefinitions = container.getComponentByType(PropertyDefinitions.class);
- assertThat(propertyDefinitions.get("foo"), notNullValue());
- assertThat(propertyDefinitions.get("foo").getDefaultValue(), is("bar"));
+ assertThat(propertyDefinitions.get("foo")).isNotNull();
+ assertThat(propertyDefinitions.get("foo").getDefaultValue()).isEqualTo("bar");
}
@Test
@@ -113,8 +113,8 @@ public class ComponentContainerTest {
container.declareExtension(plugin, ComponentWithProperty.class);
PropertyDefinitions propertyDefinitions = container.getComponentByType(PropertyDefinitions.class);
- assertThat(propertyDefinitions.get("foo"), notNullValue());
- assertThat(container.getComponentByType(ComponentWithProperty.class), nullValue());
+ assertThat(propertyDefinitions.get("foo")).isNotNull();
+ assertThat(container.getComponentByType(ComponentWithProperty.class)).isNull();
}
@Test
@@ -124,8 +124,8 @@ public class ComponentContainerTest {
container.addExtension(plugin, ComponentWithProperty.class);
PropertyDefinitions propertyDefinitions = container.getComponentByType(PropertyDefinitions.class);
- assertThat(propertyDefinitions.get("foo"), notNullValue());
- assertThat(container.getComponentByType(ComponentWithProperty.class), notNullValue());
+ assertThat(propertyDefinitions.get("foo")).isNotNull();
+ assertThat(container.getComponentByType(ComponentWithProperty.class)).isNotNull();
}
public static class StartableComponent {