Skip to content

Commit

Permalink
a) Usage of val where it could be used. Retained type initialisation …
Browse files Browse the repository at this point in the history
…for when it has to be latter passed down as an arg to a function.

b) .equalsIgnoreCase in selector tests has crept in during the previous sonar lints, corrected the same.
c) Addressed sonar lint issues on license block
  • Loading branch information
koushikr committed Oct 18, 2021
1 parent 4fcfe36 commit 9bd12b9
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public class RoundRobinServiceNodeSelectorTest {
@Test
public void testRandomNodeSelector(){
final RoundRobinServiceNodeSelector<TestNodeData> roundRobinSelector = new RoundRobinServiceNodeSelector<TestNodeData>();
List<ServiceNode<TestNodeData>> serviceNodes = Lists.newArrayList();
final List<ServiceNode<TestNodeData>> serviceNodes = Lists.newArrayList();
serviceNodes.add(new ServiceNode<>("localhost-1", 9000, TestNodeData.builder().nodeId(1).build()));
serviceNodes.add(new ServiceNode<>("localhost-2", 9001, TestNodeData.builder().nodeId(2).build()));
serviceNodes.add(new ServiceNode<>("localhost-3", 9002, TestNodeData.builder().nodeId(3).build()));
ServiceNode<TestNodeData> select = roundRobinSelector.select(serviceNodes);
Assert.assertTrue(select.getHost().equalsIgnoreCase("localhost-2"));
Assert.assertEquals("localhost-2", select.getHost());
select = roundRobinSelector.select(serviceNodes);
Assert.assertTrue(select.getHost().equalsIgnoreCase("localhost-3"));
Assert.assertEquals("localhost-3", select.getHost());
select = roundRobinSelector.select(serviceNodes);
Assert.assertTrue(select.getHost().equalsIgnoreCase("localhost-1"));
Assert.assertEquals("localhost-1", select.getHost());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ListShardSelectorTest {

@Test
public void testNoOpShardSelector(){
final ListBasedServiceRegistry serviceRegistry = RegistryTestUtils.getUnshardedRegistry();
final ListBasedServiceRegistry<TestNodeData> serviceRegistry = RegistryTestUtils.getUnshardedRegistry();
final ListShardSelector<TestNodeData, Criteria<TestNodeData>> shardSelector = new ListShardSelector<>();
final List<ServiceNode<TestNodeData>> nodes = shardSelector.nodes(CriteriaUtils.getCriteria(1), serviceRegistry);
Assert.assertFalse(nodes.isEmpty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public HttpNodeDataStoreConnector(
.connectionPool(new ConnectionPool(1, 30, TimeUnit.SECONDS))
.build();
this.config = config;
this.mapper = null != mapper ? mapper : new ObjectMapper();
this.mapper = mapper;
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2015 Flipkart Internet Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,6 +16,7 @@
package com.flipkart.ranger.http.common;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.flipkart.ranger.core.units.TestNodeData;
import com.flipkart.ranger.http.config.HttpClientConfig;
import org.junit.Assert;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2015 Flipkart Internet Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2015 Flipkart Internet Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2015 Flipkart Internet Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2015 Flipkart Internet Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2015 Flipkart Internet Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Copyright 2015 Flipkart Internet Pvt. Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -51,8 +51,8 @@ public TestNodeData(@JsonProperty("farmId") String farmId) {

@Test
public void testProvider() throws Exception {
TestNodeData nm5NodeData = TestNodeData.builder().farmId("nm5").build();
ServiceNode<TestNodeData> testNode = new ServiceNode<>("localhost-1", 80, nm5NodeData);
val nm5NodeData = TestNodeData.builder().farmId("nm5").build();
val testNode = new ServiceNode<>("localhost-1", 80, nm5NodeData);
val response = MAPPER.writeValueAsBytes(
ServiceRegistrationResponse.builder()
.success(true)
Expand All @@ -69,7 +69,7 @@ public void testProvider() throws Exception {
.connectionTimeoutMs(30_000)
.operationTimeoutMs(30_000)
.build();
ServiceProvider<TestNodeData, HttpRequestDataSerializer<TestNodeData>> serviceProvider = new HttpShardedServiceProviderBuilder<TestNodeData>()
val serviceProvider = new HttpShardedServiceProviderBuilder<TestNodeData>()
.withNamespace("testns")
.withServiceName("test")
.withHostname("localhost-1")
Expand Down

0 comments on commit 9bd12b9

Please sign in to comment.