Skip to content

Commit

Permalink
GEODE-7869: Cleanup warnings in geode-management
Browse files Browse the repository at this point in the history
  • Loading branch information
jake-at-work committed Mar 16, 2020
1 parent 4fb85db commit fa9bf79
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void testRegisterSynchronization() throws Exception {
TransactionImpl txn = (TransactionImpl) tm.getTransaction();
Synchronization sync = new SyncImpl();
txn.registerSynchronization(sync);
assertTrue("Synchronization not registered succesfully", txn.getSyncList().contains(sync));
assertTrue("Synchronization not registered successfully", txn.getSyncList().contains(sync));
utx.commit();
}

Expand All @@ -81,7 +81,7 @@ public void testNotifyBeforeCompletion() throws Exception {
SyncImpl sync = new SyncImpl();
txn.registerSynchronization(sync);
txn.notifyBeforeCompletion();
assertTrue("Notify before completion not executed succesfully", sync.befCompletion);
assertTrue("Notify before completion not executed successfully", sync.befCompletion);
utx.commit();
}

Expand All @@ -92,7 +92,7 @@ public void testNotifyAfterCompletion() throws Exception {
SyncImpl sync = new SyncImpl();
txn.registerSynchronization(sync);
txn.notifyAfterCompletion(1);
assertTrue("Notify after completion not executed succesfully", sync.aftCompletion);
assertTrue("Notify after completion not executed successfully", sync.aftCompletion);
utx.commit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected boolean operateOnPartitionedRegion(ClusterDistributionManager dm, Part
exceptionMsgs.append(ex.getMessage()).append("\n");
}
logger.debug("Got an MultiIndexCreationException with \n: {}", exceptionMsgs);
logger.debug("{} indexes were created succesfully", failedIndexNames.size());
logger.debug("{} indexes were created successfully", failedIndexNames.size());
}
replyEx = new ReplyException(
"Remote Index Creation Failed", exx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public void stopProcessing() {
if (logger.isDebugEnabled()) {
logger.debug(
"ConcurrentParallelGatewaySenderEventProcessor: {} stopped dispatching: {}",
(b ? "Successfully" : "Unsuccesfully"), this);
(b ? "Successfully" : "Unsuccessfully"), this);
}
} catch (ExecutionException e) {
// we don't expect any exception but if caught then eat it and log warning
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public void stopProcessing() {
boolean b = f.get();
if (logger.isDebugEnabled()) {
logger.debug("ConcurrentSerialGatewaySenderEventProcessor: {} stopped dispatching: {}",
(b ? "Successfully" : "Unsuccesfully"), this);
(b ? "Successfully" : "Unsuccessfully"), this);
}
} catch (ExecutionException e) {
// we don't expect any exception but if caught then eat it and log
Expand Down
1 change: 1 addition & 0 deletions geode-management/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
apply from: "${rootDir}/${scriptDir}/standard-subproject-configuration.gradle"

apply from: "${project.projectDir}/../gradle/publish-java.gradle"
apply from: "${project.projectDir}/../gradle/warnings.gradle"

dependencies {
compile(platform(project(':boms:geode-all-bom')))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.apache.geode.management.api;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -56,30 +57,30 @@ public List<EntityGroupInfo<T, R>> getEntityGroupInfo() {
// this annotation makes sure we always show the result even though it's an empty list
@JsonInclude
public List<EntityInfo<T, R>> getResult() {
return entities.values().stream().collect(Collectors.toList());
return new ArrayList<>(entities.values());
}

public void setResult(List<EntityInfo<T, R>> entities) {
this.entities.clear();
for (EntityInfo entity : entities) {
for (EntityInfo<T, R> entity : entities) {
this.entities.put(entity.getId(), entity);
}
}

public void addEntityInfo(EntityInfo<T, R> entityInfo) {
this.entities.put(entityInfo.getId(), entityInfo);
entities.put(entityInfo.getId(), entityInfo);
}

@JsonIgnore
public void setEntityGroupInfo(List<EntityGroupInfo<T, R>> entityGroupInfos) {
this.entities.clear();
for (EntityGroupInfo entityGroupInfo : entityGroupInfos) {
entities.clear();
for (EntityGroupInfo<T, R> entityGroupInfo : entityGroupInfos) {
String id = entityGroupInfo.getConfiguration().getId();
EntityInfo<T, R> entity = this.entities.get(id);
EntityInfo<T, R> entity = entities.get(id);
if (entity == null) {
entity = new EntityInfo<>();
entity.setId(id);
this.entities.put(id, entity);
entities.put(id, entity);
}
entity.getGroups().add(entityGroupInfo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private <T extends AbstractConfiguration<?>> ClusterManagementRealizationResult
.getBody();
}

private static <T> HttpEntity makeEntity(T config) {
private static <T> HttpEntity<?> makeEntity(T config) {
HttpHeaders headers = new HttpHeaders();
headers.add(INCLUDE_CLASS_HEADER, "true");
if (config instanceof HasFile) {
Expand All @@ -251,7 +251,7 @@ private static <T> HttpEntity makeEntity(T config) {
if (file != null) {
content.add(HasFile.FILE_PARAM, new FileSystemResource(file));
content.add(HasFile.CONFIG_PARAM, config);
return new HttpEntity(content, headers);
return new HttpEntity<>(content, headers);
}
}
return new HttpEntity<>(config, headers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.apache.geode.management.api.RestTemplateClusterManagementServiceTransport;
import org.apache.geode.management.internal.ClientClusterManagementService;

public abstract class BaseManagementServiceBuilder<T extends BaseManagementServiceBuilder> {
public abstract class BaseManagementServiceBuilder<T extends BaseManagementServiceBuilder<?>> {

private ClusterManagementServiceTransport transport;

Expand Down Expand Up @@ -53,40 +53,44 @@ private ClusterManagementServiceTransport configureTransport() {
return transport;
}

@SuppressWarnings("unchecked")
private T self() {
return (T) this;
}

public T setTransport(ClusterManagementServiceTransport transport) {
this.transport = transport;
return (T) this;
return self();
}

public T setAuthToken(String token) {
this.authToken = token;
return (T) this;
authToken = token;
return self();
}

public T setSslContext(SSLContext sslContext) {
this.sslContext = sslContext;
return (T) this;
return self();
}

public T setUsername(String username) {
this.username = username;
return (T) this;
return self();
}

public T setPassword(String password) {
this.password = password;
return (T) this;
return self();
}

public T setHostnameVerifier(HostnameVerifier hostnameVerifier) {
this.hostnameVerifier = hostnameVerifier;
return (T) this;
return self();
}

public T setFollowRedirects(boolean followRedirects) {
this.followRedirects = followRedirects;
return (T) this;
return self();
}

protected abstract ConnectionConfig createConnectionConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void serialization() throws JsonProcessingException {

System.out.println(json);

@SuppressWarnings("unchecked")
ClusterManagementGetResult<Region, RuntimeRegionInfo> deserialized =
mapper.readValue(json, ClusterManagementGetResult.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class ClusterManagementListResultTest {
private ObjectMapper mapper = GeodeJsonMapper.getMapper();

@Before
public void before() throws Exception {
public void before() {
list = new ClusterManagementListResult<>();
}

Expand Down Expand Up @@ -81,7 +81,7 @@ public void serialization() throws Exception {
assertThat(json).containsOnlyOnce("\"self\":\"#HREF/management/v1/regions/regionA\"")
.containsOnlyOnce("\"self\":\"#HREF/management/v1/regions/regionB\"");

ClusterManagementListResult result =
ClusterManagementListResult<?, ?> result =
mapper.readValue(json, ClusterManagementListResult.class);

assertThat(result.getEntityGroupInfo()).hasSize(3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,22 @@ public void serialize() throws Exception {
null, "id", null, null);
String json = mapper.writeValueAsString(result);
System.out.println(json);
@SuppressWarnings("unchecked")
ClusterManagementOperationResult<ClusterManagementOperation<OperationResult>, OperationResult> value =
mapper.readValue(json, ClusterManagementOperationResult.class);
assertThat(value.getStatusMessage()).isEqualTo("Success!!");
}

@Test
public void serializeRebal() throws Exception {
public void serializeRebalance() throws Exception {
RebalanceOperation rebalanceOperation = new RebalanceOperation();
rebalanceOperation.setOperator("operator");
ClusterManagementOperationResult<RebalanceOperation, RebalanceResult> result =
new ClusterManagementOperationResult(StatusCode.OK, "Success!!", new Date(), new Date(),
new ClusterManagementOperationResult<>(StatusCode.OK, "Success!!", new Date(), new Date(),
rebalanceOperation, "id", new RebalanceResultImpl(), null);
String json = mapper.writeValueAsString(result);
System.out.println(json);
@SuppressWarnings("unchecked")
ClusterManagementOperationResult<RebalanceOperation, RebalanceResult> value =
mapper.readValue(json, ClusterManagementOperationResult.class);
assertThat(value.getStatusMessage()).isEqualTo("Success!!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public void serialization() throws JsonProcessingException {

System.out.println(json);

@SuppressWarnings("unchecked")
EntityInfo<Region, RuntimeRegionInfo> deserialized =
mapper.readValue(json, EntityInfo.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,13 @@
import org.apache.geode.management.configuration.AbstractConfiguration;
import org.apache.geode.management.configuration.Links;
import org.apache.geode.management.operation.RebalanceOperation;
import org.apache.geode.management.runtime.RebalanceResult;

public class RestTemplateClusterManagementServiceTransportTest {
private RestTemplateClusterManagementServiceTransport restServiceTransport;
private RestTemplate restTemplate;
private ResponseEntity responseEntity;
private AbstractConfiguration configuration;
private ResponseEntity<?> responseEntity;
private AbstractConfiguration<?> configuration;
private Links links;
private ClusterManagementRealizationResult realizationSuccess;
private ClusterManagementListResult listResult;
private ClusterManagementGetResult getResult;
private ClusterManagementOperationResult<RebalanceOperation, RebalanceResult> rebalanceOperationResult;

@Before
public void init() {
Expand All @@ -60,14 +55,13 @@ public void init() {
links = mock(Links.class);
when(configuration.getLinks()).thenReturn(links);

realizationSuccess = mock(ClusterManagementRealizationResult.class);
ClusterManagementRealizationResult realizationSuccess =
mock(ClusterManagementRealizationResult.class);
when(realizationSuccess.isSuccessful()).thenReturn(true);
listResult = mock(ClusterManagementListResult.class);
ClusterManagementListResult<?, ?> listResult = mock(ClusterManagementListResult.class);
when(listResult.isSuccessful()).thenReturn(true);
getResult = mock(ClusterManagementGetResult.class);
ClusterManagementGetResult<?, ?> getResult = mock(ClusterManagementGetResult.class);
when(getResult.isSuccessful()).thenReturn(true);

rebalanceOperationResult = mock(ClusterManagementOperationResult.class);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class ClusterManagementServiceBuilderTest {
@Rule
public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties();

@SuppressWarnings("unchecked")
private <T> T getFieldValue(Object target, String fieldName) throws NoSuchFieldException {

Field field = ReflectionUtils.findField(target.getClass(), fieldName);
Expand Down Expand Up @@ -82,7 +83,7 @@ public void settingSSLUsesHTTPS() throws NoSuchAlgorithmException, NoSuchFieldEx
}

@Test
public void notSettingSSLUsesHTTP() throws NoSuchAlgorithmException, NoSuchFieldException {
public void notSettingSSLUsesHTTP() throws NoSuchFieldException {
ClusterManagementService cms =
new ClusterManagementServiceBuilder().setHost(HOST).setPort(PORT).build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class ClientClusterManagementServiceTest {
private ClusterManagementOperationResult<RebalanceOperation, RebalanceResult> successOperationResult;
private ClusterManagementOperation<OperationResult> operation;

@SuppressWarnings("unchecked")
@Before
public void init() {
serviceTransport = mock(ClusterManagementServiceTransport.class);
Expand Down Expand Up @@ -101,6 +102,7 @@ public void updateNotImplemented() {

@Test
public void listCallsSubmitMessageAndReturnsResult() {
@SuppressWarnings("unchecked")
ClusterManagementListResult<AbstractConfiguration<RuntimeInfo>, RuntimeInfo> successListResult =
mock(ClusterManagementListResult.class);
when(successListResult.isSuccessful()).thenReturn(true);
Expand All @@ -115,6 +117,7 @@ public void listCallsSubmitMessageAndReturnsResult() {

@Test
public void getCallsSubmitMessageAndReturnsResult() {
@SuppressWarnings("unchecked")
ClusterManagementGetResult<AbstractConfiguration<RuntimeInfo>, RuntimeInfo> successGetResult =
mock(ClusterManagementGetResult.class);
when(successGetResult.isSuccessful()).thenReturn(true);
Expand Down Expand Up @@ -192,6 +195,7 @@ public void getOperationCallsSubmitMessageAndReturnsFutureThatCompletes() throws

@Test
public void listOperationCallsSubmitMessageAndReturnsResult() {
@SuppressWarnings("unchecked")
ClusterManagementListOperationsResult<ClusterManagementOperation<OperationResult>, OperationResult> successListOperationsResult =
mock(ClusterManagementListOperationsResult.class);
when(successListOperationsResult.isSuccessful()).thenReturn(true);
Expand Down

0 comments on commit fa9bf79

Please sign in to comment.