Skip to content

Commit

Permalink
fix checkstyle
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutosh Gupta committed Aug 7, 2022
1 parent 54fc62d commit 3a52ab5
Show file tree
Hide file tree
Showing 26 changed files with 261 additions and 259 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ private void testRPCTimeout(String rpcClass) throws Exception {
proxy.startContainers(allRequests);
} catch (Exception e) {
LOG.info(StringUtils.stringifyException(e));
assertEquals(SocketTimeoutException.class.getName(), e.getClass().getName(), "Error, exception is not: "
+ SocketTimeoutException.class.getName());
assertEquals(SocketTimeoutException.class.getName(), e.getClass().getName(),
"Error, exception is not: " + SocketTimeoutException.class.getName());
return;
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ private void testRPCTimeout(String rpcClass) throws Exception {
proxy.updateContainer(request);
} catch (Exception e) {
LOG.info(StringUtils.stringifyException(e));
assertEquals(SocketTimeoutException.class.getName(), e.getClass().getName(), "Error, exception is not: "
+ SocketTimeoutException.class.getName());
assertEquals(SocketTimeoutException.class.getName(), e.getClass().getName(),
"Error, exception is not: " + SocketTimeoutException.class.getName());
return;
}
} finally {
Expand Down Expand Up @@ -159,11 +159,9 @@ public StartContainersResponse startContainers(
}

@Override
public StopContainersResponse
stopContainers(StopContainersRequest requests) throws YarnException,
IOException {
Exception e = new Exception("Dummy function", new Exception(
"Dummy function cause"));
public StopContainersResponse stopContainers(StopContainersRequest requests)
throws YarnException, IOException {
Exception e = new Exception("Dummy function", new Exception("Dummy function cause"));
throw new YarnException(e);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ void testFactoryProvider() {
try {
serverFactory = RpcFactoryProvider.getServerFactory(conf);
} catch (YarnRuntimeException e) {
fail("Error while loading factory using reflection: [" + RpcServerFactoryPBImpl.class.getName() + "]");
fail(
"Error while loading factory using reflection: [" + RpcServerFactoryPBImpl.class.getName()
+ "]");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,31 +78,29 @@ void testGetApplicationsRequest() {
assertEquals(requestFromProto, request);

// verify all properties are the same as original request
assertEquals(
requestFromProto.getApplicationStates(), appStates, "ApplicationStates from proto is not the same with original request");
assertEquals(requestFromProto.getApplicationStates(), appStates,
"ApplicationStates from proto is not the same with original request");

assertEquals(
requestFromProto.getApplicationTags(), tags, "ApplicationTags from proto is not the same with original request");
assertEquals(requestFromProto.getApplicationTags(), tags,
"ApplicationTags from proto is not the same with original request");

assertEquals(
requestFromProto.getApplicationTypes(), types, "ApplicationTypes from proto is not the same with original request");
assertEquals(requestFromProto.getApplicationTypes(), types,
"ApplicationTypes from proto is not the same with original request");

assertEquals(
requestFromProto.getStartRange(), Range.between(startBegin, startEnd), "StartRange from proto is not the same with original request");
assertEquals(requestFromProto.getStartRange(), Range.between(startBegin, startEnd),
"StartRange from proto is not the same with original request");

assertEquals(
requestFromProto.getFinishRange(),
Range.between(finishBegin, finishEnd),
assertEquals(requestFromProto.getFinishRange(), Range.between(finishBegin, finishEnd),
"FinishRange from proto is not the same with original request");

assertEquals(
requestFromProto.getLimit(), limit, "Limit from proto is not the same with original request");
assertEquals(requestFromProto.getLimit(), limit,
"Limit from proto is not the same with original request");

assertEquals(
requestFromProto.getQueues(), queues, "Queues from proto is not the same with original request");
assertEquals(requestFromProto.getQueues(), queues,
"Queues from proto is not the same with original request");

assertEquals(
requestFromProto.getUsers(), users, "Users from proto is not the same with original request");
assertEquals(requestFromProto.getUsers(), users,
"Users from proto is not the same with original request");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ void testGetMemory() {
long memorySize = Integer.MAX_VALUE + 1L;
res.setMemorySize(memorySize);

assertEquals(memorySize,
res.getMemorySize(),
"No need to cast if both are long");
assertEquals(Integer.MAX_VALUE, res.getMemory(), "Cast to Integer.MAX_VALUE if the long is greater than "
+ "Integer.MAX_VALUE");
assertEquals(memorySize, res.getMemorySize(), "No need to cast if both are long");
assertEquals(Integer.MAX_VALUE, res.getMemory(),
"Cast to Integer.MAX_VALUE if the long is greater than " + "Integer.MAX_VALUE");
}

@Test
Expand All @@ -118,8 +116,8 @@ void testGetVirtualCores() {
assertEquals(vcores,
res.getResourceInformation("vcores").getValue(),
"No need to cast if both are long");
assertEquals(Integer.MAX_VALUE, res.getVirtualCores(), "Cast to Integer.MAX_VALUE if the long is greater than "
+ "Integer.MAX_VALUE");
assertEquals(Integer.MAX_VALUE, res.getVirtualCores(),
"Cast to Integer.MAX_VALUE if the long is greater than " + "Integer.MAX_VALUE");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,32 @@ public class TestGetApplicationsRequestPBImpl {

@MethodSource("data")
@ParameterizedTest
void testAppTagsLowerCaseConversionDefault(GetApplicationsRequestPBImpl impl) {
initTestGetApplicationsRequestPBImpl(impl);
impl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
impl.getApplicationTags().forEach(s ->
assertEquals(s, s.toLowerCase()));
void testAppTagsLowerCaseConversionDefault(
GetApplicationsRequestPBImpl applicationsRequestPBImpl) {
initTestGetApplicationsRequestPBImpl(applicationsRequestPBImpl);
applicationsRequestPBImpl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
applicationsRequestPBImpl.getApplicationTags().forEach(s -> assertEquals(s, s.toLowerCase()));
}

@MethodSource("data")
@ParameterizedTest
void testAppTagsLowerCaseConversionDisabled(GetApplicationsRequestPBImpl impl) {
initTestGetApplicationsRequestPBImpl(impl);
void testAppTagsLowerCaseConversionDisabled(
GetApplicationsRequestPBImpl applicationsRequestPBImpl) {
initTestGetApplicationsRequestPBImpl(applicationsRequestPBImpl);
GetApplicationsRequestPBImpl.setForceLowerCaseTags(false);
impl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
impl.getApplicationTags().forEach(s ->
assertNotEquals(s, s.toLowerCase()));
applicationsRequestPBImpl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
applicationsRequestPBImpl.getApplicationTags()
.forEach(s -> assertNotEquals(s, s.toLowerCase()));
}

@MethodSource("data")
@ParameterizedTest
void testAppTagsLowerCaseConversionEnabled(GetApplicationsRequestPBImpl impl) {
initTestGetApplicationsRequestPBImpl(impl);
void testAppTagsLowerCaseConversionEnabled(
GetApplicationsRequestPBImpl applicationsRequestPBImpl) {
initTestGetApplicationsRequestPBImpl(applicationsRequestPBImpl);
GetApplicationsRequestPBImpl.setForceLowerCaseTags(true);
impl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
impl.getApplicationTags().forEach(s ->
assertEquals(s, s.toLowerCase()));
applicationsRequestPBImpl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
applicationsRequestPBImpl.getApplicationTags().forEach(s -> assertEquals(s, s.toLowerCase()));
}

public static Collection<Object[]> data() {
Expand All @@ -73,7 +74,8 @@ public static Collection<Object[]> data() {
return list;
}

public void initTestGetApplicationsRequestPBImpl(GetApplicationsRequestPBImpl impl) {
public void initTestGetApplicationsRequestPBImpl(
GetApplicationsRequestPBImpl applicationsRequestPBImpl) {
this.impl = impl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,34 @@ public class TestApplicationSubmissionContextPBImpl {

@MethodSource("data")
@ParameterizedTest
void testAppTagsLowerCaseConversionDefault(ApplicationSubmissionContextPBImpl impl) {
initTestApplicationSubmissionContextPBImpl(impl);
impl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
impl.getApplicationTags().forEach(s ->
assertEquals(s, s.toLowerCase()));
void testAppTagsLowerCaseConversionDefault(
ApplicationSubmissionContextPBImpl applicationSubmissionContextPB) {
initTestApplicationSubmissionContextPBImpl(applicationSubmissionContextPB);
applicationSubmissionContextPB.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
applicationSubmissionContextPB.getApplicationTags()
.forEach(s -> assertEquals(s, s.toLowerCase()));
}

@MethodSource("data")
@ParameterizedTest
void testAppTagsLowerCaseConversionDisabled(ApplicationSubmissionContextPBImpl impl) {
initTestApplicationSubmissionContextPBImpl(impl);
void testAppTagsLowerCaseConversionDisabled(
ApplicationSubmissionContextPBImpl applicationSubmissionContextPB) {
initTestApplicationSubmissionContextPBImpl(applicationSubmissionContextPB);
ApplicationSubmissionContextPBImpl.setForceLowerCaseTags(false);
impl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
impl.getApplicationTags().forEach(s ->
assertNotEquals(s, s.toLowerCase()));
applicationSubmissionContextPB.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
applicationSubmissionContextPB.getApplicationTags()
.forEach(s -> assertNotEquals(s, s.toLowerCase()));
}

@MethodSource("data")
@ParameterizedTest
void testAppTagsLowerCaseConversionEnabled(ApplicationSubmissionContextPBImpl impl) {
initTestApplicationSubmissionContextPBImpl(impl);
void testAppTagsLowerCaseConversionEnabled(
ApplicationSubmissionContextPBImpl applicationSubmissionContextPB) {
initTestApplicationSubmissionContextPBImpl(applicationSubmissionContextPB);
ApplicationSubmissionContextPBImpl.setForceLowerCaseTags(true);
impl.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
impl.getApplicationTags().forEach(s ->
assertEquals(s, s.toLowerCase()));
applicationSubmissionContextPB.setApplicationTags(Sets.newHashSet("ABcd", "efgH"));
applicationSubmissionContextPB.getApplicationTags()
.forEach(s -> assertEquals(s, s.toLowerCase()));
}

public static Collection<Object[]> data() {
Expand All @@ -73,7 +76,8 @@ public static Collection<Object[]> data() {
return list;
}

public void initTestApplicationSubmissionContextPBImpl(ApplicationSubmissionContextPBImpl impl) {
this.impl = impl;
public void initTestApplicationSubmissionContextPBImpl(
ApplicationSubmissionContextPBImpl applicationSubmissionContextPB) {
this.impl = applicationSubmissionContextPB;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ void testTimelineDomain() throws Exception {
" test_reader_group+" + (i + 1), domain.getReaders());
assertEquals("test_writer_user_" + (i + 1) +
" test_writer_group+" + (i + 1), domain.getWriters());
assertEquals(new Long(0L), domain.getCreatedTime());
assertEquals(new Long(1L), domain.getModifiedTime());
assertEquals(Long.valueOf(0L), domain.getCreatedTime());
assertEquals(Long.valueOf(1L), domain.getModifiedTime());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ void testTimelineEntities() throws Exception {
Iterator<Map.Entry<Long, Number>> itr =
metric1.getValues().entrySet().iterator();
Map.Entry<Long, Number> entry = itr.next();
assertEquals(new Long(3L), entry.getKey());
assertEquals(Long.valueOf(3L), entry.getKey());
assertEquals(3.0D, entry.getValue());
entry = itr.next();
assertEquals(new Long(2L), entry.getKey());
assertEquals(Long.valueOf(2L), entry.getKey());
assertEquals(2, entry.getValue());
entry = itr.next();
assertEquals(new Long(1L), entry.getKey());
assertEquals(Long.valueOf(1L), entry.getKey());
assertEquals(1.0F, entry.getValue());
assertFalse(itr.hasNext());
entity.addMetric(metric1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,8 @@ private static void assertFail() {
}

private void assertException(TimelineClientImpl client, RuntimeException ce) {
assertTrue(
ce
.getMessage().contains("Connection retries limit exceeded"), "Handler exception for reason other than retry: " + ce.toString());
assertTrue(ce.getMessage().contains("Connection retries limit exceeded"),
"Handler exception for reason other than retry: " + ce.toString());
// we would expect this exception here, check if the client has retried
assertTrue(client.connector.connectionRetry.getRetired(),
"Retry filter didn't perform any retries! ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ void testExceptionCalls() throws Exception {
client.putEntities(generateEntity("2"));
fail("Sync calls are expected to throw exception");
} catch (YarnException e) {
assertEquals("ActualException", e.getCause().getMessage(), "Same exception needs to be thrown");
assertEquals("ActualException", e.getCause().getMessage(),
"Same exception needs to be thrown");
}
}

Expand Down Expand Up @@ -358,15 +359,15 @@ void testSetTimelineToken() throws Exception {
Token token = Token.newInstance(
new byte[0], "kind", new byte[0], "service");
client.setTimelineCollectorInfo(CollectorInfo.newInstance(null, token));
assertNull(client.currentTimelineToken, "Timeline token in v2 client should not be set as token kind " +
"is unexepcted.");
assertNull(client.currentTimelineToken,
"Timeline token in v2 client should not be set as token kind " + "is unexepcted.");
assertEquals(0, ugi.getTokens().size());

token = Token.newInstance(new byte[0], TimelineDelegationTokenIdentifier.
KIND_NAME.toString(), new byte[0], null);
client.setTimelineCollectorInfo(CollectorInfo.newInstance(null, token));
assertNull(client.currentTimelineToken, "Timeline token in v2 client should not be set as serice is " +
"not set.");
assertNull(client.currentTimelineToken,
"Timeline token in v2 client should not be set as serice is " + "not set.");
assertEquals(0, ugi.getTokens().size());

TimelineDelegationTokenIdentifier ident =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ void testGetRMServiceId() throws Exception {
@Test
void testGetRMId() throws Exception {
conf.set(YarnConfiguration.RM_HA_ID, RM1_NODE_ID);
assertEquals(RM1_NODE_ID, HAUtil.getRMHAId(conf), "Does not honor " + YarnConfiguration.RM_HA_ID);
assertEquals(RM1_NODE_ID, HAUtil.getRMHAId(conf),
"Does not honor " + YarnConfiguration.RM_HA_ID);

conf.clear();
assertNull(HAUtil.getRMHAId(conf), "Return null when " + YarnConfiguration.RM_HA_ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ void testRMWebUrlSpecified() throws Exception {
assertEquals(24543,
Integer.parseInt(parts[parts.length - 1]),
"RM Web URL Port is incrrect");
assertNotSame(
"http://rmtesting:24543", rmWebUrl, "RM Web Url not resolved correctly. Should not be rmtesting");
assertNotSame("http://rmtesting:24543", rmWebUrl,
"RM Web Url not resolved correctly. Should not be rmtesting");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ void testDispatcherMetricsHistogram() throws Exception {
String metricName = metric.name();
if (expectedValues.containsKey(metricName)) {
Long expectedValue = expectedValues.get(metricName);
assertEquals(
expectedValue, metric.value(), "Metric " + metricName + " doesn't have expected value");
assertEquals(expectedValue, metric.value(),
"Metric " + metricName + " doesn't have expected value");
testResults.add(metricName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@ private void verifyRemoteExceptionUnwrapping(

assertTrue(expectedLocalException.isInstance(t), "Expected exception [" + expectedLocalException
+ "] but found " + t);
assertTrue(
t
.getMessage().contains(message), "Expected message [" + message + "] but found " + t.getMessage());
assertTrue(t.getMessage().contains(message),
"Expected message [" + message + "] but found " + t.getMessage());
}

private static class YarnTestException extends YarnException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,10 @@ private void testReadAcontainerLog(boolean logUploadedTime) throws Exception {

logWriter.append(logKey, spyLogValue);
}

// make sure permission are correct on the file
FileStatus fsStatus = fs.getFileStatus(remoteAppLogFile);
assertEquals(FsPermission.createImmutable((short) 0640), fsStatus.getPermission(), "permissions on log aggregation file are wrong");

FileStatus fsStatus = fs.getFileStatus(remoteAppLogFile);
assertEquals(FsPermission.createImmutable((short) 0640), fsStatus.getPermission(),
"permissions on log aggregation file are wrong");
LogReader logReader = new LogReader(conf, remoteAppLogFile);
LogKey rLogKey = new LogKey();
DataInputStream dis = logReader.next(rLogKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,8 @@ private void verifyFileControllerInstance(
new FileWriter(new File(logPath.toString(), "testLog"))) {
writer.write("test");
}
assertTrue(className.isInstance(
factory.getFileControllerForRead(appId, APP_OWNER)), "The used LogAggregationFileController is not instance of "
+ className.getSimpleName());
assertTrue(className.isInstance(factory.getFileControllerForRead(appId, APP_OWNER)),
"The used LogAggregationFileController is not instance of " + className.getSimpleName());
} finally {
fs.delete(logPath, true);
}
Expand Down
Loading

0 comments on commit 3a52ab5

Please sign in to comment.