From 74f41e7262a029bb95424c76f870134b4133b014 Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Fri, 17 Jan 2020 11:53:57 +0100 Subject: Reduce number of contstructors --- .../vespa/config/server/ApplicationRepository.java | 14 ----------- .../config/server/ApplicationRepositoryTest.java | 27 ++++++++++------------ .../server/http/v2/ApplicationHandlerTest.java | 1 + 3 files changed, 13 insertions(+), 29 deletions(-) (limited to 'configserver/src') diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java index 35c41711a6e..87c971a6cd6 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java @@ -141,20 +141,6 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye clock); } - // For testing - public ApplicationRepository(TenantRepository tenantRepository, - Provisioner hostProvisioner, - Orchestrator orchestrator, - LogRetriever logRetriever, - Clock clock) { - this(tenantRepository, - hostProvisioner, - orchestrator, - new ConfigserverConfig(new ConfigserverConfig.Builder()), - logRetriever, - clock); - } - // For testing public ApplicationRepository(TenantRepository tenantRepository, Provisioner hostProvisioner, diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java index b7eea3eb7fd..cd507178733 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java @@ -144,11 +144,7 @@ public class ApplicationRepositoryTest { @Test public void getLogs() { - applicationRepository = new ApplicationRepository(tenantRepository, - provisioner, - orchestrator, - new MockLogRetriever(), - clock); + applicationRepository = createApplicationRepository(); deployApp(testAppLogServerWithContainer); HttpResponse response = applicationRepository.getLogs(applicationId(), Optional.empty(), ""); assertEquals(200, response.getStatus()); @@ -156,11 +152,7 @@ public class ApplicationRepositoryTest { @Test public void getLogsForHostname() { - applicationRepository = new ApplicationRepository(tenantRepository, - provisioner, - orchestrator, - new MockLogRetriever(), - clock); + applicationRepository = createApplicationRepository(); ApplicationId applicationId = ApplicationId.from("hosted-vespa", "tenant-host", "default"); deployApp(testAppLogServerWithContainer, new PrepareParams.Builder().applicationId(applicationId).build()); HttpResponse response = applicationRepository.getLogs(applicationId, Optional.of("localhost"), ""); @@ -169,11 +161,7 @@ public class ApplicationRepositoryTest { @Test(expected = IllegalArgumentException.class) public void refuseToGetLogsFromHostnameNotInApplication() { - applicationRepository = new ApplicationRepository(tenantRepository, - provisioner, - orchestrator, - new MockLogRetriever(), - clock); + applicationRepository = createApplicationRepository(); deployApp(testAppLogServerWithContainer); HttpResponse response = applicationRepository.getLogs(applicationId(), Optional.of("host123.fake.yahoo.com"), ""); assertEquals(200, response.getStatus()); @@ -329,6 +317,15 @@ public class ApplicationRepositoryTest { assertEquals(0, applicationRepository.deleteExpiredRemoteSessions(Duration.ofSeconds(0))); } + private ApplicationRepository createApplicationRepository() { + return new ApplicationRepository(tenantRepository, + provisioner, + orchestrator, + new ConfigserverConfig(new ConfigserverConfig.Builder()), + new MockLogRetriever(), + clock); + } + private PrepareResult prepareAndActivateApp(File application) throws IOException { FilesApplicationPackage appDir = FilesApplicationPackage.fromFile(application); ApplicationId applicationId = applicationId(); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java index 87f4363050b..c2e78f2dd63 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java @@ -75,6 +75,7 @@ public class ApplicationHandlerTest { applicationRepository = new ApplicationRepository(tenantRepository, provisioner, orchestrator, + new ConfigserverConfig(new ConfigserverConfig.Builder()), new MockLogRetriever(), Clock.systemUTC()); listApplicationsHandler = new ListApplicationsHandler(ListApplicationsHandler.testOnlyContext(), -- cgit v1.2.3