From d03488dd98ce518c303a69e4d093e8dc8b962f4d Mon Sep 17 00:00:00 2001 From: Martin Polden Date: Mon, 4 Sep 2017 13:27:49 +0200 Subject: Remove fest-assert One test library is sufficient. --- controller-server/pom.xml | 13 +++++------ .../vespa/hosted/controller/ControllerTest.java | 22 ++++++++---------- .../maintenance/MetricsReporterTest.java | 13 ++++++----- .../rotation/ControllerRotationRepositoryTest.java | 27 +++++++++++++--------- 4 files changed, 38 insertions(+), 37 deletions(-) (limited to 'controller-server') diff --git a/controller-server/pom.xml b/controller-server/pom.xml index f9e84693452..fa21098a092 100644 --- a/controller-server/pom.xml +++ b/controller-server/pom.xml @@ -119,6 +119,12 @@ + + junit + junit + test + + com.yahoo.vespa application @@ -145,13 +151,6 @@ test - - org.easytesting - fest-assert - 1.4 - test - - diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java index 8b5dad1fa9a..95f4400b2b5 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/ControllerTest.java @@ -31,6 +31,8 @@ import com.yahoo.vespa.hosted.controller.api.identifiers.TenantId; import com.yahoo.vespa.hosted.controller.api.identifiers.UserGroup; import com.yahoo.vespa.hosted.controller.api.integration.BuildService.BuildJob; import com.yahoo.vespa.hosted.controller.api.integration.athens.NToken; +import com.yahoo.vespa.hosted.controller.api.integration.athens.mock.AthensDbMock; +import com.yahoo.vespa.hosted.controller.api.integration.athens.mock.NTokenMock; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.ApplicationRevision; import com.yahoo.vespa.hosted.controller.application.Change; @@ -46,8 +48,6 @@ import com.yahoo.vespa.hosted.controller.persistence.ApplicationSerializer; import com.yahoo.vespa.hosted.controller.versions.DeploymentStatistics; import com.yahoo.vespa.hosted.controller.versions.VersionStatus; import com.yahoo.vespa.hosted.controller.versions.VespaVersion; -import com.yahoo.vespa.hosted.controller.api.integration.athens.mock.AthensDbMock; -import com.yahoo.vespa.hosted.controller.api.integration.athens.mock.NTokenMock; import org.junit.Test; import java.io.IOException; @@ -68,7 +68,6 @@ import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobTy import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.productionUsWest1; import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest; import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest; -import static org.fest.assertions.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -385,8 +384,8 @@ public class ControllerTest { tester.controller().applications().createApplication(applicationId, Optional.empty()); // Verify that Athens domain does not have any relations to tenant/application yet - assertThat(mockDomain.applications.keySet()).isEmpty(); - assertThat(mockDomain.isVespaTenant).isFalse(); + assertTrue(mockDomain.applications.keySet().isEmpty()); + assertFalse(mockDomain.isVespaTenant); // Migrate tenant to Athens NToken nToken = new NTokenMock("token"); @@ -395,15 +394,12 @@ public class ControllerTest { // Verify that tenant is migrated Tenant tenant = tester.controller().tenants().tenant(tenantId).get(); - assertThat(tenant.isAthensTenant()) - .isTrue(); - assertThat(tenant.getAthensDomain().get()) - .isEqualTo(athensDomain); + assertTrue(tenant.isAthensTenant()); + assertEquals(athensDomain, tenant.getAthensDomain().get()); // Verify that domain knows about tenant and application - assertThat(mockDomain.isVespaTenant) - .isTrue(); - assertThat(mockDomain.applications.keySet()) - .contains(new com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId(applicationName)); + assertTrue(mockDomain.isVespaTenant); + assertTrue(mockDomain.applications.keySet().contains( + new com.yahoo.vespa.hosted.controller.api.identifiers.ApplicationId(applicationName))); } @Test diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java index 3244307e91c..621e189ba37 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/MetricsReporterTest.java @@ -28,8 +28,9 @@ import java.util.Map; import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.component; import static com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest; -import static org.fest.assertions.Assertions.assertThat; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; import static org.mockito.Matchers.anyListOf; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.when; @@ -54,7 +55,7 @@ public class MetricsReporterTest { assertDimension(metricContext, "tenantName", "ciintegrationtests"); assertDimension(metricContext, "app", "restart.default"); assertDimension(metricContext, "zone", "prod.cd-us-east-1"); - assertThat(metricEntry.getValue().get(MetricsReporter.convergeMetric).longValue()).isEqualTo(727); + assertEquals(727, metricEntry.getValue().get(MetricsReporter.convergeMetric).longValue()); } @Test @@ -95,11 +96,11 @@ public class MetricsReporterTest { ControllerTester tester = new ControllerTester(); String hostname = "fake-node2.test"; MapContext metricContext = getMetricsForHost(tester.controller(), hostname); - assertThat(metricContext.getDimensions().get("zone")).isNull(); + assertNull(metricContext.getDimensions().get("zone")); } private void assertDimension(MapContext metricContext, String dimensionName, String expectedValue) { - assertThat(metricContext.getDimensions().get(dimensionName)).isNotNull().isEqualTo(expectedValue); + assertEquals(expectedValue, metricContext.getDimensions().get(dimensionName)); } private MetricsReporter setupMetricsReporter(Controller controller, MetricsMock metricsMock, SystemName system) throws IOException { @@ -120,10 +121,10 @@ public class MetricsReporterTest { MetricsReporter metricsReporter = setupMetricsReporter(controller, metricsMock, SystemName.main); metricsReporter.maintain(); - assertThat(metricsMock.getMetrics()).isNotEmpty(); + assertFalse(metricsMock.getMetrics().isEmpty()); Map> metrics = metricsMock.getMetricsFilteredByHost(hostname); - assertThat(metrics).hasSize(1); + assertEquals(1, metrics.size()); Map.Entry> metricEntry = metrics.entrySet().iterator().next(); return metricEntry.getKey(); } diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/rotation/ControllerRotationRepositoryTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/rotation/ControllerRotationRepositoryTest.java index 8fc218a9e8b..561799529f9 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/rotation/ControllerRotationRepositoryTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/rotation/ControllerRotationRepositoryTest.java @@ -16,10 +16,12 @@ import org.junit.rules.ExpectedException; import java.io.StringReader; import java.net.URI; +import java.util.Collection; import java.util.Collections; import java.util.Set; -import static org.fest.assertions.Assertions.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * @author Oyvind Gronnesby @@ -111,14 +113,14 @@ public class ControllerRotationRepositoryTest { public void application_with_rotation_reused() { Set rotations = repository.getOrAssignRotation(applicationId, deploymentSpec); Rotation assignedRotation = new Rotation(new RotationId("foo-1"), "foo-1.com"); - assertThat(rotations).containsOnly(assignedRotation); + assertContainsOnly(assignedRotation, rotations); } @Test public void names_stripped() { Set rotations = repositoryWhitespaces.getOrAssignRotation(applicationId, deploymentSpec); Rotation assignedRotation = new Rotation(new RotationId("foo-1"), "foo-1.com"); - assertThat(rotations).containsOnly(assignedRotation); + assertContainsOnly(assignedRotation, rotations); } @Test @@ -126,7 +128,7 @@ public class ControllerRotationRepositoryTest { ApplicationId other = ApplicationId.from("othertenant", "otherapplication", "default"); Set rotations = repository.getOrAssignRotation(other, deploymentSpec); Rotation assignedRotation = new Rotation(new RotationId("foo-2"), "foo-2.com"); - assertThat(rotations).containsOnly(assignedRotation); + assertContainsOnly(assignedRotation, rotations); } @Test @@ -154,30 +156,28 @@ public class ControllerRotationRepositoryTest { public void application_with_rotation_but_does_not_qualify() { Set rotations = repository.getOrAssignRotation(applicationId, deploymentSpecOneRegion); Rotation assignedRotation = new Rotation(new RotationId("foo-1"), "foo-1.com"); - assertThat(rotations).containsOnly(assignedRotation); + assertContainsOnly(assignedRotation, rotations); } @Test public void application_with_rotation_is_listed() { repository.getOrAssignRotation(applicationId, deploymentSpec); Set uris = repository.getRotationUris(applicationId); - assertThat(uris).isEqualTo( - Collections.singleton(URI.create("http://tumblr-search.msbe.global.vespa.yahooapis.com:4080/")) - ); + assertEquals(Collections.singleton(URI.create("http://tumblr-search.msbe.global.vespa.yahooapis.com:4080/")), uris); } @Test public void application_without_rotation_is_empty() { ApplicationId other = ApplicationId.from("othertenant", "otherapplication", "default"); Set uris = repository.getRotationUris(other); - assertThat(uris).isEmpty(); + assertTrue(uris.isEmpty()); } @Test public void application_without_serviceid_and_two_regions() { ApplicationId other = ApplicationId.from("othertenant", "otherapplication", "default"); Set rotations = repository.getOrAssignRotation(other, deploymentSpecNoServiceId); - assertThat(rotations).isEmpty(); + assertTrue(rotations.isEmpty()); } @Test @@ -194,7 +194,12 @@ public class ControllerRotationRepositoryTest { public void application_with_corp_region_and_two_non_corp_region() { ApplicationId other = ApplicationId.from("othertenant", "otherapplication", "default"); Set rotations = repository.getOrAssignRotation(other, deploymentSpecWithAdditionalCorpZone); - assertThat(rotations).containsOnly(new Rotation(new RotationId("foo-2"), "foo-2.com")); + assertContainsOnly(new Rotation(new RotationId("foo-2"), "foo-2.com"), rotations); + } + + private static void assertContainsOnly(T item, Collection items) { + assertTrue("Collection contains only " + item.toString(), + items.size() == 1 && items.contains(item)); } } -- cgit v1.2.3