Skip to content

Commit 80a8987

Browse files
MaxGekkdongjoon-hyun
authored andcommitted
[SPARK-29733][TESTS] Fix wrong order of parameters passed to assertEquals
### What changes were proposed in this pull request? The `assertEquals` method of JUnit Assert requires the first parameter to be the expected value. In this PR, I propose to change the order of parameters when the expected value is passed as the second parameter. ### Why are the changes needed? Wrong order of assert parameters confuses when the assert fails and the parameters have special string representation. For example: ```java assertEquals(input1.add(input2), new CalendarInterval(5, 5, 367200000000L)); ``` ``` java.lang.AssertionError: Expected :interval 5 months 5 days 101 hours Actual :interval 5 months 5 days 102 hours ``` ### Does this PR introduce any user-facing change? No ### How was this patch tested? By existing tests. Closes apache#26377 from MaxGekk/fix-order-in-assert-equals. Authored-by: Maxim Gekk <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]>
1 parent 4bcfe50 commit 80a8987

File tree

21 files changed

+119
-119
lines changed

21 files changed

+119
-119
lines changed

Diff for: common/network-common/src/test/java/org/apache/spark/network/RpcIntegrationSuite.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,14 @@ public void onFailure(Throwable e) {
260260
@Test
261261
public void singleRPC() throws Exception {
262262
RpcResult res = sendRPC("hello/Aaron");
263-
assertEquals(res.successMessages, Sets.newHashSet("Hello, Aaron!"));
263+
assertEquals(Sets.newHashSet("Hello, Aaron!"), res.successMessages);
264264
assertTrue(res.errorMessages.isEmpty());
265265
}
266266

267267
@Test
268268
public void doubleRPC() throws Exception {
269269
RpcResult res = sendRPC("hello/Aaron", "hello/Reynold");
270-
assertEquals(res.successMessages, Sets.newHashSet("Hello, Aaron!", "Hello, Reynold!"));
270+
assertEquals(Sets.newHashSet("Hello, Aaron!", "Hello, Reynold!"), res.successMessages);
271271
assertTrue(res.errorMessages.isEmpty());
272272
}
273273

@@ -295,7 +295,7 @@ public void doubleTrouble() throws Exception {
295295
@Test
296296
public void sendSuccessAndFailure() throws Exception {
297297
RpcResult res = sendRPC("hello/Bob", "throw error/the", "hello/Builder", "return error/!");
298-
assertEquals(res.successMessages, Sets.newHashSet("Hello, Bob!", "Hello, Builder!"));
298+
assertEquals(Sets.newHashSet("Hello, Bob!", "Hello, Builder!"), res.successMessages);
299299
assertErrorsContain(res.errorMessages, Sets.newHashSet("Thrown: the", "Returned: !"));
300300
}
301301

Diff for: common/unsafe/src/test/java/org/apache/spark/unsafe/PlatformUtilSuite.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -114,25 +114,25 @@ public void memoryDebugFillEnabledInTest() {
114114
Assert.assertTrue(MemoryAllocator.MEMORY_DEBUG_FILL_ENABLED);
115115
MemoryBlock onheap = MemoryAllocator.HEAP.allocate(1);
116116
Assert.assertEquals(
117-
Platform.getByte(onheap.getBaseObject(), onheap.getBaseOffset()),
118-
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE);
117+
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE,
118+
Platform.getByte(onheap.getBaseObject(), onheap.getBaseOffset()));
119119

120120
MemoryBlock onheap1 = MemoryAllocator.HEAP.allocate(1024 * 1024);
121121
Object onheap1BaseObject = onheap1.getBaseObject();
122122
long onheap1BaseOffset = onheap1.getBaseOffset();
123123
MemoryAllocator.HEAP.free(onheap1);
124124
Assert.assertEquals(
125-
Platform.getByte(onheap1BaseObject, onheap1BaseOffset),
126-
MemoryAllocator.MEMORY_DEBUG_FILL_FREED_VALUE);
125+
MemoryAllocator.MEMORY_DEBUG_FILL_FREED_VALUE,
126+
Platform.getByte(onheap1BaseObject, onheap1BaseOffset));
127127
MemoryBlock onheap2 = MemoryAllocator.HEAP.allocate(1024 * 1024);
128128
Assert.assertEquals(
129-
Platform.getByte(onheap2.getBaseObject(), onheap2.getBaseOffset()),
130-
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE);
129+
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE,
130+
Platform.getByte(onheap2.getBaseObject(), onheap2.getBaseOffset()));
131131

132132
MemoryBlock offheap = MemoryAllocator.UNSAFE.allocate(1);
133133
Assert.assertEquals(
134-
Platform.getByte(offheap.getBaseObject(), offheap.getBaseOffset()),
135-
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE);
134+
MemoryAllocator.MEMORY_DEBUG_FILL_CLEAN_VALUE,
135+
Platform.getByte(offheap.getBaseObject(), offheap.getBaseOffset()));
136136
MemoryAllocator.UNSAFE.free(offheap);
137137
}
138138

@@ -150,11 +150,11 @@ public void heapMemoryReuse() {
150150
// The size is greater than `HeapMemoryAllocator.POOLING_THRESHOLD_BYTES`,
151151
// reuse the previous memory which has released.
152152
MemoryBlock onheap3 = heapMem.allocate(1024 * 1024 + 1);
153-
Assert.assertEquals(onheap3.size(), 1024 * 1024 + 1);
153+
Assert.assertEquals(1024 * 1024 + 1, onheap3.size());
154154
Object obj3 = onheap3.getBaseObject();
155155
heapMem.free(onheap3);
156156
MemoryBlock onheap4 = heapMem.allocate(1024 * 1024 + 7);
157-
Assert.assertEquals(onheap4.size(), 1024 * 1024 + 7);
157+
Assert.assertEquals(1024 * 1024 + 7, onheap4.size());
158158
Assert.assertEquals(obj3, onheap4.getBaseObject());
159159
}
160160
}

Diff for: common/unsafe/src/test/java/org/apache/spark/unsafe/types/CalendarIntervalSuite.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,21 @@ public void toStringTest() {
7777
public void addTest() {
7878
CalendarInterval input1 = new CalendarInterval(3, 1, 1 * MICROS_PER_HOUR);
7979
CalendarInterval input2 = new CalendarInterval(2, 4, 100 * MICROS_PER_HOUR);
80-
assertEquals(input1.add(input2), new CalendarInterval(5, 5, 101 * MICROS_PER_HOUR));
80+
assertEquals(new CalendarInterval(5, 5, 101 * MICROS_PER_HOUR), input1.add(input2));
8181

8282
input1 = new CalendarInterval(-10, -30, -81 * MICROS_PER_HOUR);
8383
input2 = new CalendarInterval(75, 150, 200 * MICROS_PER_HOUR);
84-
assertEquals(input1.add(input2), new CalendarInterval(65, 120, 119 * MICROS_PER_HOUR));
84+
assertEquals(new CalendarInterval(65, 120, 119 * MICROS_PER_HOUR), input1.add(input2));
8585
}
8686

8787
@Test
8888
public void subtractTest() {
8989
CalendarInterval input1 = new CalendarInterval(3, 1, 1 * MICROS_PER_HOUR);
9090
CalendarInterval input2 = new CalendarInterval(2, 4, 100 * MICROS_PER_HOUR);
91-
assertEquals(input1.subtract(input2), new CalendarInterval(1, -3, -99 * MICROS_PER_HOUR));
91+
assertEquals(new CalendarInterval(1, -3, -99 * MICROS_PER_HOUR), input1.subtract(input2));
9292

9393
input1 = new CalendarInterval(-10, -30, -81 * MICROS_PER_HOUR);
9494
input2 = new CalendarInterval(75, 150, 200 * MICROS_PER_HOUR);
95-
assertEquals(input1.subtract(input2), new CalendarInterval(-85, -180, -281 * MICROS_PER_HOUR));
95+
assertEquals(new CalendarInterval(-85, -180, -281 * MICROS_PER_HOUR), input1.subtract(input2));
9696
}
9797
}

Diff for: common/unsafe/src/test/java/org/apache/spark/unsafe/types/UTF8StringSuite.java

+63-63
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ public class UTF8StringSuite {
3838
private static void checkBasic(String str, int len) {
3939
UTF8String s1 = fromString(str);
4040
UTF8String s2 = fromBytes(str.getBytes(StandardCharsets.UTF_8));
41-
assertEquals(s1.numChars(), len);
42-
assertEquals(s2.numChars(), len);
41+
assertEquals(len, s1.numChars());
42+
assertEquals(len, s2.numChars());
4343

44-
assertEquals(s1.toString(), str);
45-
assertEquals(s2.toString(), str);
44+
assertEquals(str, s1.toString());
45+
assertEquals(str, s2.toString());
4646
assertEquals(s1, s2);
4747

4848
assertEquals(s1.hashCode(), s2.hashCode());
@@ -375,20 +375,20 @@ public void pad() {
375375
@Test
376376
public void substringSQL() {
377377
UTF8String e = fromString("example");
378-
assertEquals(e.substringSQL(0, 2), fromString("ex"));
379-
assertEquals(e.substringSQL(1, 2), fromString("ex"));
380-
assertEquals(e.substringSQL(0, 7), fromString("example"));
381-
assertEquals(e.substringSQL(1, 2), fromString("ex"));
382-
assertEquals(e.substringSQL(0, 100), fromString("example"));
383-
assertEquals(e.substringSQL(1, 100), fromString("example"));
384-
assertEquals(e.substringSQL(2, 2), fromString("xa"));
385-
assertEquals(e.substringSQL(1, 6), fromString("exampl"));
386-
assertEquals(e.substringSQL(2, 100), fromString("xample"));
387-
assertEquals(e.substringSQL(0, 0), fromString(""));
388-
assertEquals(e.substringSQL(100, 4), EMPTY_UTF8);
389-
assertEquals(e.substringSQL(0, Integer.MAX_VALUE), fromString("example"));
390-
assertEquals(e.substringSQL(1, Integer.MAX_VALUE), fromString("example"));
391-
assertEquals(e.substringSQL(2, Integer.MAX_VALUE), fromString("xample"));
378+
assertEquals(fromString("ex"), e.substringSQL(0, 2));
379+
assertEquals(fromString("ex"), e.substringSQL(1, 2));
380+
assertEquals(fromString("example"), e.substringSQL(0, 7));
381+
assertEquals(fromString("ex"), e.substringSQL(1, 2));
382+
assertEquals(fromString("example"), e.substringSQL(0, 100));
383+
assertEquals(fromString("example"), e.substringSQL(1, 100));
384+
assertEquals(fromString("xa"), e.substringSQL(2, 2));
385+
assertEquals(fromString("exampl"), e.substringSQL(1, 6));
386+
assertEquals(fromString("xample"), e.substringSQL(2, 100));
387+
assertEquals(fromString(""), e.substringSQL(0, 0));
388+
assertEquals(EMPTY_UTF8, e.substringSQL(100, 4));
389+
assertEquals(fromString("example"), e.substringSQL(0, Integer.MAX_VALUE));
390+
assertEquals(fromString("example"), e.substringSQL(1, Integer.MAX_VALUE));
391+
assertEquals(fromString("xample"), e.substringSQL(2, Integer.MAX_VALUE));
392392
}
393393

394394
@Test
@@ -506,50 +506,50 @@ public void findInSet() {
506506

507507
@Test
508508
public void soundex() {
509-
assertEquals(fromString("Robert").soundex(), fromString("R163"));
510-
assertEquals(fromString("Rupert").soundex(), fromString("R163"));
511-
assertEquals(fromString("Rubin").soundex(), fromString("R150"));
512-
assertEquals(fromString("Ashcraft").soundex(), fromString("A261"));
513-
assertEquals(fromString("Ashcroft").soundex(), fromString("A261"));
514-
assertEquals(fromString("Burroughs").soundex(), fromString("B620"));
515-
assertEquals(fromString("Burrows").soundex(), fromString("B620"));
516-
assertEquals(fromString("Ekzampul").soundex(), fromString("E251"));
517-
assertEquals(fromString("Example").soundex(), fromString("E251"));
518-
assertEquals(fromString("Ellery").soundex(), fromString("E460"));
519-
assertEquals(fromString("Euler").soundex(), fromString("E460"));
520-
assertEquals(fromString("Ghosh").soundex(), fromString("G200"));
521-
assertEquals(fromString("Gauss").soundex(), fromString("G200"));
522-
assertEquals(fromString("Gutierrez").soundex(), fromString("G362"));
523-
assertEquals(fromString("Heilbronn").soundex(), fromString("H416"));
524-
assertEquals(fromString("Hilbert").soundex(), fromString("H416"));
525-
assertEquals(fromString("Jackson").soundex(), fromString("J250"));
526-
assertEquals(fromString("Kant").soundex(), fromString("K530"));
527-
assertEquals(fromString("Knuth").soundex(), fromString("K530"));
528-
assertEquals(fromString("Lee").soundex(), fromString("L000"));
529-
assertEquals(fromString("Lukasiewicz").soundex(), fromString("L222"));
530-
assertEquals(fromString("Lissajous").soundex(), fromString("L222"));
531-
assertEquals(fromString("Ladd").soundex(), fromString("L300"));
532-
assertEquals(fromString("Lloyd").soundex(), fromString("L300"));
533-
assertEquals(fromString("Moses").soundex(), fromString("M220"));
534-
assertEquals(fromString("O'Hara").soundex(), fromString("O600"));
535-
assertEquals(fromString("Pfister").soundex(), fromString("P236"));
536-
assertEquals(fromString("Rubin").soundex(), fromString("R150"));
537-
assertEquals(fromString("Robert").soundex(), fromString("R163"));
538-
assertEquals(fromString("Rupert").soundex(), fromString("R163"));
539-
assertEquals(fromString("Soundex").soundex(), fromString("S532"));
540-
assertEquals(fromString("Sownteks").soundex(), fromString("S532"));
541-
assertEquals(fromString("Tymczak").soundex(), fromString("T522"));
542-
assertEquals(fromString("VanDeusen").soundex(), fromString("V532"));
543-
assertEquals(fromString("Washington").soundex(), fromString("W252"));
544-
assertEquals(fromString("Wheaton").soundex(), fromString("W350"));
545-
546-
assertEquals(fromString("a").soundex(), fromString("A000"));
547-
assertEquals(fromString("ab").soundex(), fromString("A100"));
548-
assertEquals(fromString("abc").soundex(), fromString("A120"));
549-
assertEquals(fromString("abcd").soundex(), fromString("A123"));
550-
assertEquals(fromString("").soundex(), fromString(""));
551-
assertEquals(fromString("123").soundex(), fromString("123"));
552-
assertEquals(fromString("世界千世").soundex(), fromString("世界千世"));
509+
assertEquals(fromString("R163"), fromString("Robert").soundex());
510+
assertEquals(fromString("R163"), fromString("Rupert").soundex());
511+
assertEquals(fromString("R150"), fromString("Rubin").soundex());
512+
assertEquals(fromString("A261"), fromString("Ashcraft").soundex());
513+
assertEquals(fromString("A261"), fromString("Ashcroft").soundex());
514+
assertEquals(fromString("B620"), fromString("Burroughs").soundex());
515+
assertEquals(fromString("B620"), fromString("Burrows").soundex());
516+
assertEquals(fromString("E251"), fromString("Ekzampul").soundex());
517+
assertEquals(fromString("E251"), fromString("Example").soundex());
518+
assertEquals(fromString("E460"), fromString("Ellery").soundex());
519+
assertEquals(fromString("E460"), fromString("Euler").soundex());
520+
assertEquals(fromString("G200"), fromString("Ghosh").soundex());
521+
assertEquals(fromString("G200"), fromString("Gauss").soundex());
522+
assertEquals(fromString("G362"), fromString("Gutierrez").soundex());
523+
assertEquals(fromString("H416"), fromString("Heilbronn").soundex());
524+
assertEquals(fromString("H416"), fromString("Hilbert").soundex());
525+
assertEquals(fromString("J250"), fromString("Jackson").soundex());
526+
assertEquals(fromString("K530"), fromString("Kant").soundex());
527+
assertEquals(fromString("K530"), fromString("Knuth").soundex());
528+
assertEquals(fromString("L000"), fromString("Lee").soundex());
529+
assertEquals(fromString("L222"), fromString("Lukasiewicz").soundex());
530+
assertEquals(fromString("L222"), fromString("Lissajous").soundex());
531+
assertEquals(fromString("L300"), fromString("Ladd").soundex());
532+
assertEquals(fromString("L300"), fromString("Lloyd").soundex());
533+
assertEquals(fromString("M220"), fromString("Moses").soundex());
534+
assertEquals(fromString("O600"), fromString("O'Hara").soundex());
535+
assertEquals(fromString("P236"), fromString("Pfister").soundex());
536+
assertEquals(fromString("R150"), fromString("Rubin").soundex());
537+
assertEquals(fromString("R163"), fromString("Robert").soundex());
538+
assertEquals(fromString("R163"), fromString("Rupert").soundex());
539+
assertEquals(fromString("S532"), fromString("Soundex").soundex());
540+
assertEquals(fromString("S532"), fromString("Sownteks").soundex());
541+
assertEquals(fromString("T522"), fromString("Tymczak").soundex());
542+
assertEquals(fromString("V532"), fromString("VanDeusen").soundex());
543+
assertEquals(fromString("W252"), fromString("Washington").soundex());
544+
assertEquals(fromString("W350"), fromString("Wheaton").soundex());
545+
546+
assertEquals(fromString("A000"), fromString("a").soundex());
547+
assertEquals(fromString("A100"), fromString("ab").soundex());
548+
assertEquals(fromString("A120"), fromString("abc").soundex());
549+
assertEquals(fromString("A123"), fromString("abcd").soundex());
550+
assertEquals(fromString(""), fromString("").soundex());
551+
assertEquals(fromString("123"), fromString("123").soundex());
552+
assertEquals(fromString("世界千世"), fromString("世界千世").soundex());
553553
}
554554

555555
@Test
@@ -849,7 +849,7 @@ public void skipWrongFirstByte() {
849849

850850
for (int i = 0; i < wrongFirstBytes.length; ++i) {
851851
c[0] = (byte)wrongFirstBytes[i];
852-
assertEquals(fromBytes(c).numChars(), 1);
852+
assertEquals(1, fromBytes(c).numChars());
853853
}
854854
}
855855
}

Diff for: core/src/test/java/org/apache/spark/launcher/SparkLauncherSuite.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ public static class InProcessTestApp {
323323

324324
public static void main(String[] args) throws Exception {
325325
assertNotEquals(0, args.length);
326-
assertEquals(args[0], "hello");
326+
assertEquals("hello", args[0]);
327327
new SparkContext().stop();
328328

329329
synchronized (LOCK) {
@@ -340,7 +340,7 @@ public static class ErrorInProcessTestApp {
340340

341341
public static void main(String[] args) {
342342
assertNotEquals(0, args.length);
343-
assertEquals(args[0], "hello");
343+
assertEquals("hello", args[0]);
344344
throw DUMMY_EXCEPTION;
345345
}
346346
}

Diff for: core/src/test/java/org/apache/spark/util/SerializableConfigurationSuite.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ public void testSerializableConfiguration() {
5050
hadoopConfiguration.set("test.property", "value");
5151
SerializableConfiguration scs = new SerializableConfiguration(hadoopConfiguration);
5252
SerializableConfiguration actual = rdd.map(val -> scs).collect().get(0);
53-
assertEquals(actual.value().get("test.property"), "value");
53+
assertEquals("value", actual.value().get("test.property"));
5454
}
5555
}

Diff for: core/src/test/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorterSuite.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -222,15 +222,15 @@ public void testSortingEmptyArrays() throws Exception {
222222
public void testSortTimeMetric() throws Exception {
223223
final UnsafeExternalSorter sorter = newSorter();
224224
long prevSortTime = sorter.getSortTimeNanos();
225-
assertEquals(prevSortTime, 0);
225+
assertEquals(0, prevSortTime);
226226

227227
sorter.insertRecord(null, 0, 0, 0, false);
228228
sorter.spill();
229229
assertThat(sorter.getSortTimeNanos(), greaterThan(prevSortTime));
230230
prevSortTime = sorter.getSortTimeNanos();
231231

232232
sorter.spill(); // no sort needed
233-
assertEquals(sorter.getSortTimeNanos(), prevSortTime);
233+
assertEquals(prevSortTime, sorter.getSortTimeNanos());
234234

235235
sorter.insertRecord(null, 0, 0, 0, false);
236236
UnsafeSorterIterator iter = sorter.getSortedIterator();

Diff for: launcher/src/test/java/org/apache/spark/launcher/ChildProcAppHandleSuite.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,23 @@ public void testRedirectsSimple() throws Exception {
7777
SparkLauncher launcher = new SparkLauncher();
7878
launcher.redirectError(ProcessBuilder.Redirect.PIPE);
7979
assertNotNull(launcher.errorStream);
80-
assertEquals(launcher.errorStream.type(), ProcessBuilder.Redirect.Type.PIPE);
80+
assertEquals(ProcessBuilder.Redirect.Type.PIPE, launcher.errorStream.type());
8181

8282
launcher.redirectOutput(ProcessBuilder.Redirect.PIPE);
8383
assertNotNull(launcher.outputStream);
84-
assertEquals(launcher.outputStream.type(), ProcessBuilder.Redirect.Type.PIPE);
84+
assertEquals(ProcessBuilder.Redirect.Type.PIPE, launcher.outputStream.type());
8585
}
8686

8787
@Test
8888
public void testRedirectLastWins() throws Exception {
8989
SparkLauncher launcher = new SparkLauncher();
9090
launcher.redirectError(ProcessBuilder.Redirect.PIPE)
9191
.redirectError(ProcessBuilder.Redirect.INHERIT);
92-
assertEquals(launcher.errorStream.type(), ProcessBuilder.Redirect.Type.INHERIT);
92+
assertEquals(ProcessBuilder.Redirect.Type.INHERIT, launcher.errorStream.type());
9393

9494
launcher.redirectOutput(ProcessBuilder.Redirect.PIPE)
9595
.redirectOutput(ProcessBuilder.Redirect.INHERIT);
96-
assertEquals(launcher.outputStream.type(), ProcessBuilder.Redirect.Type.INHERIT);
96+
assertEquals(ProcessBuilder.Redirect.Type.INHERIT, launcher.outputStream.type());
9797
}
9898

9999
@Test

Diff for: mllib/src/test/java/org/apache/spark/ml/classification/JavaLogisticRegressionSuite.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void setUp() throws IOException {
5050
@Test
5151
public void logisticRegressionDefaultParams() {
5252
LogisticRegression lr = new LogisticRegression();
53-
Assert.assertEquals(lr.getLabelCol(), "label");
53+
Assert.assertEquals("label", lr.getLabelCol());
5454
LogisticRegressionModel model = lr.fit(dataset);
5555
model.transform(dataset).createOrReplaceTempView("prediction");
5656
Dataset<Row> predictions = spark.sql("SELECT label, probability, prediction FROM prediction");
@@ -119,8 +119,8 @@ public void logisticRegressionPredictorClassifierMethods() {
119119
for (Row row : trans1.collectAsList()) {
120120
Vector raw = (Vector) row.get(0);
121121
Vector prob = (Vector) row.get(1);
122-
Assert.assertEquals(raw.size(), 2);
123-
Assert.assertEquals(prob.size(), 2);
122+
Assert.assertEquals(2, raw.size());
123+
Assert.assertEquals(2, prob.size());
124124
double probFromRaw1 = 1.0 / (1.0 + Math.exp(-raw.apply(1)));
125125
Assert.assertEquals(0, Math.abs(prob.apply(1) - probFromRaw1), eps);
126126
Assert.assertEquals(0, Math.abs(prob.apply(0) - (1.0 - probFromRaw1)), eps);

Diff for: mllib/src/test/java/org/apache/spark/ml/classification/JavaOneVsRestSuite.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ public void setUp() throws IOException {
6262
public void oneVsRestDefaultParams() {
6363
OneVsRest ova = new OneVsRest();
6464
ova.setClassifier(new LogisticRegression());
65-
Assert.assertEquals(ova.getLabelCol(), "label");
66-
Assert.assertEquals(ova.getPredictionCol(), "prediction");
65+
Assert.assertEquals("label", ova.getLabelCol());
66+
Assert.assertEquals("prediction", ova.getPredictionCol());
6767
OneVsRestModel ovaModel = ova.fit(dataset);
6868
Dataset<Row> predictions = ovaModel.transform(dataset).select("label", "prediction");
6969
predictions.collectAsList();
70-
Assert.assertEquals(ovaModel.getLabelCol(), "label");
71-
Assert.assertEquals(ovaModel.getPredictionCol(), "prediction");
70+
Assert.assertEquals("label", ovaModel.getLabelCol());
71+
Assert.assertEquals("prediction", ovaModel.getPredictionCol());
7272
}
7373
}

Diff for: mllib/src/test/java/org/apache/spark/ml/feature/JavaHashingTFSuite.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void hashingTF() {
6464
Dataset<Row> rescaledData = idfModel.transform(featurizedData);
6565
for (Row r : rescaledData.select("features", "label").takeAsList(3)) {
6666
Vector features = r.getAs(0);
67-
Assert.assertEquals(features.size(), numFeatures);
67+
Assert.assertEquals(numFeatures, features.size());
6868
}
6969
}
7070
}

Diff for: mllib/src/test/java/org/apache/spark/ml/feature/JavaVectorIndexerSuite.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public void vectorIndexerAPI() {
4747
.setOutputCol("indexed")
4848
.setMaxCategories(2);
4949
VectorIndexerModel model = indexer.fit(data);
50-
Assert.assertEquals(model.numFeatures(), 2);
50+
Assert.assertEquals(2, model.numFeatures());
5151
Map<Integer, Map<Double, Integer>> categoryMaps = model.javaCategoryMaps();
52-
Assert.assertEquals(categoryMaps.size(), 1);
52+
Assert.assertEquals(1, categoryMaps.size());
5353
Dataset<Row> indexedData = model.transform(data);
5454
}
5555
}

Diff for: mllib/src/test/java/org/apache/spark/ml/feature/JavaVectorSlicerSuite.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void vectorSlice() {
6363

6464
for (Row r : output.select("userFeatures", "features").takeAsList(2)) {
6565
Vector features = r.getAs(1);
66-
Assert.assertEquals(features.size(), 2);
66+
Assert.assertEquals(2, features.size());
6767
}
6868
}
6969
}

0 commit comments

Comments
 (0)