Skip to content

Commit a3e2ad1

Browse files
ryeon9445chhsiao90
authored andcommitted
Fix the order of actual value and expected value in the test code
1 parent 5f46c1f commit a3e2ad1

File tree

9 files changed

+31
-37
lines changed

9 files changed

+31
-37
lines changed

core/src/test/java/org/modelmapper/bugs/GH109.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@ protected void configure() {
3636
Source s = new Source();
3737
s.value = Integer.valueOf(42);
3838
Destination dest = modelMapper.map(s, Destination.class);
39-
assertEquals(42, dest.value);
39+
assertEquals(dest.value, 42);
4040
}
4141
}

core/src/test/java/org/modelmapper/bugs/GH204.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@ protected void configure() {
6464

6565
modelMapper.validate();
6666

67-
assertEquals("foo",
68-
modelMapper.map(new SomeDto("foo"), SomeEntity.class).otherValue);
69-
assertEquals("bar",
70-
modelMapper.map(new SomeEntity("bar"), SomeDto.class).someValue);
67+
assertEquals(modelMapper.map(new SomeDto("foo"), SomeEntity.class).otherValue, "foo");
68+
assertEquals(modelMapper.map(new SomeEntity("bar"), SomeDto.class).someValue, "bar");
7169
}
7270

7371
public void shouldMappingMethod2() {
@@ -86,10 +84,8 @@ protected void configure() {
8684

8785
modelMapper.validate();
8886

89-
assertEquals("foo",
90-
modelMapper.map(new SomeDto("foo"), SomeEntity.class).otherValue);
91-
assertEquals("bar",
92-
modelMapper.map(new SomeEntity("bar"), SomeDto.class).someValue);
87+
assertEquals(modelMapper.map(new SomeDto("foo"), SomeEntity.class).otherValue, "foo");
88+
assertEquals(modelMapper.map(new SomeEntity("bar"), SomeDto.class).someValue, "bar");
9389
}
9490

9591
public void shouldMappingMethod3() {
@@ -108,9 +104,7 @@ protected void configure() {
108104

109105
modelMapper.validate();
110106

111-
assertEquals("foo",
112-
modelMapper.map(new SomeDto("foo"), SomeEntity.class).otherValue);
113-
assertEquals("bar",
114-
modelMapper.map(new SomeEntity("bar"), SomeDto.class).someValue);
107+
assertEquals(modelMapper.map(new SomeDto("foo"), SomeEntity.class).otherValue, "foo");
108+
assertEquals(modelMapper.map(new SomeEntity("bar"), SomeDto.class).someValue, "bar");
115109
}
116110
}

core/src/test/java/org/modelmapper/bugs/GH249.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void shouldMap() {
7171
pojoAgent.setRoles(new HashSet<Role>(Arrays.asList(new Role("foo"), new Role("bar"))));
7272

7373
DomainAgent domainAgent = modelMapper.map(pojoAgent, DomainAgent.class);
74-
assertEquals(2, domainAgent.getRoles().size());
74+
assertEquals(domainAgent.getRoles().size(), 2);
7575
}
7676

7777
public void shouldMapExistDestination() {
@@ -83,6 +83,6 @@ public void shouldMapExistDestination() {
8383

8484
modelMapper.map(pojoAgent, domainAgent);
8585

86-
assertEquals(2, domainAgent.getRoles().size());
86+
assertEquals(domainAgent.getRoles().size(), 2);
8787
}
8888
}

core/src/test/java/org/modelmapper/bugs/GH379.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void shouldMapGeneric() {
4141

4242
Type destinationType = new TypeToken<PageModel<SubjectModel>>(){}.getType();
4343
PageModel<SubjectModel> destination = modelMapper.map(page, destinationType);
44-
assertEquals(2, destination.items.size());
44+
assertEquals(destination.items.size(), 2);
4545
assertEquals(SubjectModel.class, destination.items.get(0).getClass());
4646
}
4747
}

core/src/test/java/org/modelmapper/bugs/GH38.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ protected void configure() {
4747
Mockito.when(a.getName()).thenReturn("hello");
4848
B b = modelMapper.map(a, B.class);
4949

50-
Assert.assertEquals("hello", b.getNameProp());
50+
Assert.assertEquals(b.getNameProp(), "hello");
5151
}
5252
}

core/src/test/java/org/modelmapper/bugs/GH386.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ public void map() {
7070
OuterDto outerDto = new OuterDto(2L,"dto", Arrays.asList(innerDto));
7171

7272
modelMapper.map(outer, outerDto);
73-
assertEquals(2L, (long) outerDto.id);
74-
assertEquals(1, outerDto.inners.size());
75-
assertEquals(1L, (long) outerDto.inners.get(0).id);
76-
assertEquals("domain", outerDto.inners.get(0).description);
77-
assertEquals("domain", outerDto.inners.get(0).name);
73+
assertEquals((long) outerDto.id, 2L);
74+
assertEquals(outerDto.inners.size(), 1);
75+
assertEquals((long) outerDto.inners.get(0).id, 1L);
76+
assertEquals(outerDto.inners.get(0).description, "domain");
77+
assertEquals(outerDto.inners.get(0).name, "domain");
7878
}
7979
}

core/src/test/java/org/modelmapper/functional/builder/BuilderTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ public void shouldMap() {
100100

101101
Source source = new Source("foo", "bar");
102102
Destination destination = modelMapper.map(source, Destination.Builder.class).build();
103-
assertEquals("foo", destination.foo);
104-
assertEquals("bar", destination.bar);
103+
assertEquals(destination.foo, "foo");
104+
assertEquals(destination.bar, "bar");
105105
}
106106

107107
public void shouldMapWithDifferentPrefix() {
@@ -112,7 +112,7 @@ public void shouldMapWithDifferentPrefix() {
112112

113113
Source source = new Source("foo", "bar");
114114
Destination destination = modelMapper.map(source, Destination.BuilderWith.class).build();
115-
assertEquals("foo", destination.foo);
116-
assertEquals("bar", destination.bar);
115+
assertEquals(destination.foo, "foo");
116+
assertEquals(destination.bar, "bar");
117117
}
118118
}

core/src/test/java/org/modelmapper/internal/converter/BooleanConverterTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public void shouldThrowOnInvalidString() {
4747

4848
protected void testConversionValues(String[] trueValues, String[] falseValues) {
4949
for (int i = 0; i < trueValues.length; i++)
50-
assertEquals(Boolean.TRUE, convert(trueValues[i]));
50+
assertEquals(convert(trueValues[i]), Boolean.TRUE);
5151
for (int i = 0; i < falseValues.length; i++)
52-
assertEquals(Boolean.FALSE, convert(falseValues[i]));
52+
assertEquals(convert(falseValues[i]), Boolean.FALSE);
5353
}
5454

5555
public void testSupported() {

core/src/test/java/org/modelmapper/internal/converter/NumberConverterTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ public void shouldThrowOnNotANumber() {
239239

240240
@Test(dataProvider = "typesProvider")
241241
public void testBooleanToNumber(Class<?> type) {
242-
assertEquals(0, ((Number) convert(Boolean.FALSE, type)).intValue());
243-
assertEquals(1, ((Number) convert(Boolean.TRUE, type)).intValue());
242+
assertEquals(((Number) convert(Boolean.FALSE, type)).intValue(), 0);
243+
assertEquals(((Number) convert(Boolean.TRUE, type)).intValue(), 1);
244244
}
245245

246246
public void testInvalidByteAmount() {
@@ -253,13 +253,13 @@ public void testInvalidByteAmount() {
253253
assertEquals(new Byte(Byte.MAX_VALUE), convert(max, Byte.class));
254254

255255
try {
256-
assertEquals(null, convert(minMinusOne, Byte.class));
256+
assertEquals(convert(minMinusOne, Byte.class), null);
257257
fail();
258258
} catch (Exception e) {
259259
}
260260

261261
try {
262-
assertEquals(null, convert(maxPlusOne, Byte.class));
262+
assertEquals(convert(maxPlusOne, Byte.class), null);
263263
fail();
264264
} catch (Exception e) {
265265
}
@@ -272,7 +272,7 @@ public void testInvalidFloatAmount() {
272272
assertEquals(new Float(Float.MAX_VALUE), convert(max, Float.class));
273273

274274
try {
275-
assertEquals(null, convert(tooBig, Float.class));
275+
assertEquals(convert(tooBig, Float.class), null);
276276
fail("More than maximum, expected ConversionException");
277277
} catch (Exception expected) {
278278
}
@@ -288,13 +288,13 @@ public void testInvalidIntegerAmount() {
288288
assertEquals(new Integer(Integer.MAX_VALUE), convert(max, Integer.class));
289289

290290
try {
291-
assertEquals(null, convert(minMinusOne, Integer.class));
291+
assertEquals(convert(minMinusOne, Integer.class), null);
292292
fail("Less than minimum, expected ConversionException");
293293
} catch (Exception expected) {
294294
}
295295

296296
try {
297-
assertEquals(null, convert(maxPlusOne, Integer.class));
297+
assertEquals(convert(maxPlusOne, Integer.class), null);
298298
fail("More than maximum, expected ConversionException");
299299
} catch (Exception expected) {
300300
}
@@ -310,13 +310,13 @@ public void testInvalidShortAmount() {
310310
assertEquals(new Short(Short.MAX_VALUE), convert(max, Short.class));
311311

312312
try {
313-
assertEquals(null, convert(minMinusOne, Short.class));
313+
assertEquals(convert(minMinusOne, Short.class), null);
314314
fail("Less than minimum, expected ConversionException");
315315
} catch (Exception expected) {
316316
}
317317

318318
try {
319-
assertEquals(null, convert(maxPlusOne, Short.class));
319+
assertEquals(convert(maxPlusOne, Short.class), null);
320320
fail("More than maximum, expected ConversionException");
321321
} catch (Exception expected) {
322322
}

0 commit comments

Comments
 (0)