Skip to content

Commit

Permalink
Reduce some unnecessary Guava usage
Browse files Browse the repository at this point in the history
  • Loading branch information
chadlwilson committed Oct 2, 2023
1 parent e3b8a92 commit b5629d9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.thoughtworks.go.server.service;

import com.google.common.collect.ImmutableMap;
import com.thoughtworks.go.config.*;
import com.thoughtworks.go.config.elastic.ClusterProfile;
import com.thoughtworks.go.config.elastic.ElasticProfile;
Expand All @@ -30,10 +29,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import java.util.*;

import static com.thoughtworks.go.domain.JobResult.Passed;
import static com.thoughtworks.go.domain.JobResult.Unknown;
Expand Down Expand Up @@ -321,7 +317,7 @@ void shouldCreateJobPlan() {
@Test
void shouldAddElasticProfileOnJobPlan() {
ElasticProfile elasticProfile = new ElasticProfile("id", "prod-cluster");
DefaultSchedulingContext context = new DefaultSchedulingContext("foo", new Agents(), ImmutableMap.of("id", elasticProfile));
DefaultSchedulingContext context = new DefaultSchedulingContext("foo", new Agents(), Map.of("id", elasticProfile));

ArtifactTypeConfigs artifactTypeConfigs = new ArtifactTypeConfigs();
JobConfig jobConfig = new JobConfig(new CaseInsensitiveString("test"), null, artifactTypeConfigs);
Expand All @@ -336,7 +332,7 @@ void shouldAddElasticProfileOnJobPlan() {
void shouldAddElasticProfileAndClusterProfileOnJobPlan() {
ElasticProfile elasticProfile = new ElasticProfile("id", "clusterId");
ClusterProfile clusterProfile = new ClusterProfile("clusterId", "pluginId");
DefaultSchedulingContext context = new DefaultSchedulingContext("foo", new Agents(), ImmutableMap.of("id", elasticProfile), ImmutableMap.of("clusterId", clusterProfile));
DefaultSchedulingContext context = new DefaultSchedulingContext("foo", new Agents(), Map.of("id", elasticProfile), Map.of("clusterId", clusterProfile));

ArtifactTypeConfigs artifactTypeConfigs = new ArtifactTypeConfigs();
JobConfig jobConfig = new JobConfig(new CaseInsensitiveString("test"), null, artifactTypeConfigs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.thoughtworks.go.server.service;

import com.google.common.collect.ImmutableMap;
import com.thoughtworks.go.config.*;
import com.thoughtworks.go.config.commands.EntityConfigUpdateCommand;
import com.thoughtworks.go.config.exceptions.RecordNotFoundException;
Expand Down Expand Up @@ -536,7 +535,7 @@ class EnvironmentConfigSyncTest {

@Test
void shouldSyncEnvironmentsFromAgentAssociationInDB1() {
shouldSyncEnvironmentsFromAgentAssociationInDB(ImmutableMap.of(
shouldSyncEnvironmentsFromAgentAssociationInDB(Map.of(
"dev", "uuid1",
"test", "uuid1",
"stage", "uuid2",
Expand All @@ -546,15 +545,15 @@ void shouldSyncEnvironmentsFromAgentAssociationInDB1() {

@Test
void shouldSyncEnvironmentsFromAgentAssociationInDB2() {
shouldSyncEnvironmentsFromAgentAssociationInDB(ImmutableMap.of(
shouldSyncEnvironmentsFromAgentAssociationInDB(Map.of(
"dev", "uuid1",
"stage", "uuid2"
));
}

@Test
void shouldSyncEnvironmentsFromAgentAssociationInDB5() {
shouldSyncEnvironmentsFromAgentAssociationInDB(ImmutableMap.of(
shouldSyncEnvironmentsFromAgentAssociationInDB(Map.of(
"dev", "uuid3",
"test", "uuid3",
"stage", "uuid3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.thoughtworks.go.spark.spa;

import com.google.common.collect.ImmutableMap;
import com.thoughtworks.go.server.newsecurity.utils.SessionUtils;
import com.thoughtworks.go.server.service.SecurityService;
import com.thoughtworks.go.spark.Routes;
Expand Down Expand Up @@ -64,14 +63,7 @@ public ModelAndView show(Request request, Response response) {
return null;
}

Map<String, Object> meta = loginLogoutHelper.buildMeta(request);

Map<String, Object> object = ImmutableMap.<String, Object>builder()
.put("viewTitle", "Login")
.put("meta", meta)
.build();

return new ModelAndView(object, null);
return new ModelAndView(Map.of("viewTitle", "Login", "meta", loginLogoutHelper.buildMeta(request)), null);
}

private boolean securityIsDisabledOrAlreadyLoggedIn(HttpServletRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.thoughtworks.go.spark.spa;

import com.google.common.collect.ImmutableMap;
import com.thoughtworks.go.server.newsecurity.utils.SessionUtils;
import com.thoughtworks.go.spark.Routes;
import com.thoughtworks.go.spark.SparkController;
Expand Down Expand Up @@ -50,13 +49,6 @@ public void setupRoutes() {
public ModelAndView show(Request request, Response response) {
SessionUtils.recreateSessionWithoutCopyingOverSessionState(request.raw());

Map<String, Object> meta = loginLogoutHelper.buildMeta(request);

Map<String, Object> object = ImmutableMap.<String, Object>builder()
.put("viewTitle", "Logout")
.put("meta", meta)
.build();

return new ModelAndView(object, null);
return new ModelAndView(Map.of("viewTitle", "Logout", "meta", loginLogoutHelper.buildMeta(request)), null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.thoughtworks.go.spark.spa;

import com.google.common.collect.ImmutableMap;
import com.thoughtworks.go.server.service.GoConfigService;
import com.thoughtworks.go.spark.Routes;
import com.thoughtworks.go.spark.SparkController;
Expand Down Expand Up @@ -55,12 +54,9 @@ public void setupRoutes() {
}

public ModelAndView index(Request request, Response response) {
Map<String, Object> meta = ImmutableMap.<String, Object>builder()
.put("smtp_configured", goConfigService.isSmtpEnabled())
.build();
Map<String, Object> object = Map.of(
"viewTitle", "Preferences",
"meta", meta
"meta", Map.of("smtp_configured", goConfigService.isSmtpEnabled())
);
return new ModelAndView(object, null);
}
Expand Down

0 comments on commit b5629d9

Please sign in to comment.