Skip to content

Commit

Permalink
Fix the order of actual value and expected value in the test code
Browse files Browse the repository at this point in the history
  • Loading branch information
ryeon9445 authored and chhsiao90 committed Jul 12, 2023
1 parent 5f46c1f commit a3e2ad1
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 37 deletions.
2 changes: 1 addition & 1 deletion core/src/test/java/org/modelmapper/bugs/GH109.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ protected void configure() {
Source s = new Source();
s.value = Integer.valueOf(42);
Destination dest = modelMapper.map(s, Destination.class);
assertEquals(42, dest.value);
assertEquals(dest.value, 42);
}
}
18 changes: 6 additions & 12 deletions core/src/test/java/org/modelmapper/bugs/GH204.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ protected void configure() {

modelMapper.validate();

assertEquals("foo",
modelMapper.map(new SomeDto("foo"), SomeEntity.class).otherValue);
assertEquals("bar",
modelMapper.map(new SomeEntity("bar"), SomeDto.class).someValue);
assertEquals(modelMapper.map(new SomeDto("foo"), SomeEntity.class).otherValue, "foo");
assertEquals(modelMapper.map(new SomeEntity("bar"), SomeDto.class).someValue, "bar");
}

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

modelMapper.validate();

assertEquals("foo",
modelMapper.map(new SomeDto("foo"), SomeEntity.class).otherValue);
assertEquals("bar",
modelMapper.map(new SomeEntity("bar"), SomeDto.class).someValue);
assertEquals(modelMapper.map(new SomeDto("foo"), SomeEntity.class).otherValue, "foo");
assertEquals(modelMapper.map(new SomeEntity("bar"), SomeDto.class).someValue, "bar");
}

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

modelMapper.validate();

assertEquals("foo",
modelMapper.map(new SomeDto("foo"), SomeEntity.class).otherValue);
assertEquals("bar",
modelMapper.map(new SomeEntity("bar"), SomeDto.class).someValue);
assertEquals(modelMapper.map(new SomeDto("foo"), SomeEntity.class).otherValue, "foo");
assertEquals(modelMapper.map(new SomeEntity("bar"), SomeDto.class).someValue, "bar");
}
}
4 changes: 2 additions & 2 deletions core/src/test/java/org/modelmapper/bugs/GH249.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void shouldMap() {
pojoAgent.setRoles(new HashSet<Role>(Arrays.asList(new Role("foo"), new Role("bar"))));

DomainAgent domainAgent = modelMapper.map(pojoAgent, DomainAgent.class);
assertEquals(2, domainAgent.getRoles().size());
assertEquals(domainAgent.getRoles().size(), 2);
}

public void shouldMapExistDestination() {
Expand All @@ -83,6 +83,6 @@ public void shouldMapExistDestination() {

modelMapper.map(pojoAgent, domainAgent);

assertEquals(2, domainAgent.getRoles().size());
assertEquals(domainAgent.getRoles().size(), 2);
}
}
2 changes: 1 addition & 1 deletion core/src/test/java/org/modelmapper/bugs/GH379.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void shouldMapGeneric() {

Type destinationType = new TypeToken<PageModel<SubjectModel>>(){}.getType();
PageModel<SubjectModel> destination = modelMapper.map(page, destinationType);
assertEquals(2, destination.items.size());
assertEquals(destination.items.size(), 2);
assertEquals(SubjectModel.class, destination.items.get(0).getClass());
}
}
2 changes: 1 addition & 1 deletion core/src/test/java/org/modelmapper/bugs/GH38.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ protected void configure() {
Mockito.when(a.getName()).thenReturn("hello");
B b = modelMapper.map(a, B.class);

Assert.assertEquals("hello", b.getNameProp());
Assert.assertEquals(b.getNameProp(), "hello");
}
}
10 changes: 5 additions & 5 deletions core/src/test/java/org/modelmapper/bugs/GH386.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public void map() {
OuterDto outerDto = new OuterDto(2L,"dto", Arrays.asList(innerDto));

modelMapper.map(outer, outerDto);
assertEquals(2L, (long) outerDto.id);
assertEquals(1, outerDto.inners.size());
assertEquals(1L, (long) outerDto.inners.get(0).id);
assertEquals("domain", outerDto.inners.get(0).description);
assertEquals("domain", outerDto.inners.get(0).name);
assertEquals((long) outerDto.id, 2L);
assertEquals(outerDto.inners.size(), 1);
assertEquals((long) outerDto.inners.get(0).id, 1L);
assertEquals(outerDto.inners.get(0).description, "domain");
assertEquals(outerDto.inners.get(0).name, "domain");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public void shouldMap() {

Source source = new Source("foo", "bar");
Destination destination = modelMapper.map(source, Destination.Builder.class).build();
assertEquals("foo", destination.foo);
assertEquals("bar", destination.bar);
assertEquals(destination.foo, "foo");
assertEquals(destination.bar, "bar");
}

public void shouldMapWithDifferentPrefix() {
Expand All @@ -112,7 +112,7 @@ public void shouldMapWithDifferentPrefix() {

Source source = new Source("foo", "bar");
Destination destination = modelMapper.map(source, Destination.BuilderWith.class).build();
assertEquals("foo", destination.foo);
assertEquals("bar", destination.bar);
assertEquals(destination.foo, "foo");
assertEquals(destination.bar, "bar");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public void shouldThrowOnInvalidString() {

protected void testConversionValues(String[] trueValues, String[] falseValues) {
for (int i = 0; i < trueValues.length; i++)
assertEquals(Boolean.TRUE, convert(trueValues[i]));
assertEquals(convert(trueValues[i]), Boolean.TRUE);
for (int i = 0; i < falseValues.length; i++)
assertEquals(Boolean.FALSE, convert(falseValues[i]));
assertEquals(convert(falseValues[i]), Boolean.FALSE);
}

public void testSupported() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ public void shouldThrowOnNotANumber() {

@Test(dataProvider = "typesProvider")
public void testBooleanToNumber(Class<?> type) {
assertEquals(0, ((Number) convert(Boolean.FALSE, type)).intValue());
assertEquals(1, ((Number) convert(Boolean.TRUE, type)).intValue());
assertEquals(((Number) convert(Boolean.FALSE, type)).intValue(), 0);
assertEquals(((Number) convert(Boolean.TRUE, type)).intValue(), 1);
}

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

try {
assertEquals(null, convert(minMinusOne, Byte.class));
assertEquals(convert(minMinusOne, Byte.class), null);
fail();
} catch (Exception e) {
}

try {
assertEquals(null, convert(maxPlusOne, Byte.class));
assertEquals(convert(maxPlusOne, Byte.class), null);
fail();
} catch (Exception e) {
}
Expand All @@ -272,7 +272,7 @@ public void testInvalidFloatAmount() {
assertEquals(new Float(Float.MAX_VALUE), convert(max, Float.class));

try {
assertEquals(null, convert(tooBig, Float.class));
assertEquals(convert(tooBig, Float.class), null);
fail("More than maximum, expected ConversionException");
} catch (Exception expected) {
}
Expand All @@ -288,13 +288,13 @@ public void testInvalidIntegerAmount() {
assertEquals(new Integer(Integer.MAX_VALUE), convert(max, Integer.class));

try {
assertEquals(null, convert(minMinusOne, Integer.class));
assertEquals(convert(minMinusOne, Integer.class), null);
fail("Less than minimum, expected ConversionException");
} catch (Exception expected) {
}

try {
assertEquals(null, convert(maxPlusOne, Integer.class));
assertEquals(convert(maxPlusOne, Integer.class), null);
fail("More than maximum, expected ConversionException");
} catch (Exception expected) {
}
Expand All @@ -310,13 +310,13 @@ public void testInvalidShortAmount() {
assertEquals(new Short(Short.MAX_VALUE), convert(max, Short.class));

try {
assertEquals(null, convert(minMinusOne, Short.class));
assertEquals(convert(minMinusOne, Short.class), null);
fail("Less than minimum, expected ConversionException");
} catch (Exception expected) {
}

try {
assertEquals(null, convert(maxPlusOne, Short.class));
assertEquals(convert(maxPlusOne, Short.class), null);
fail("More than maximum, expected ConversionException");
} catch (Exception expected) {
}
Expand Down

0 comments on commit a3e2ad1

Please sign in to comment.