Skip to content

Commit 4474734

Browse files
committed
a reformat code
1 parent cfb3447 commit 4474734

File tree

6 files changed

+56
-49
lines changed

6 files changed

+56
-49
lines changed

approvaltests-util/src/main/java/com/spun/util/ClassUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ public static <T> Class getGreatestCommonInterface(List<T> list)
207207
Class first = Queryable.as(allCommon).orderBy(Order.Descending, x -> x.getMethods().length).first();
208208
return first;
209209
}
210-
211-
public static File getAdjacentFile(Class<?> aClass, String relativeFileName) {
210+
public static File getAdjacentFile(Class<?> aClass, String relativeFileName)
211+
{
212212
return new File(getSourceDirectory(aClass), relativeFileName);
213213
}
214214
}

approvaltests/src/main/java/org/approvaltests/reporters/AbstractJUnitReporter.java

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,43 @@
77
import java.lang.reflect.InvocationTargetException;
88
import java.lang.reflect.Method;
99

10-
public abstract class AbstractJUnitReporter implements EnvironmentAwareReporter {
11-
private String className;
12-
13-
public AbstractJUnitReporter(String className) {
14-
this.className = className;
10+
public abstract class AbstractJUnitReporter implements EnvironmentAwareReporter
11+
{
12+
private String className;
13+
public AbstractJUnitReporter(String className)
14+
{
15+
this.className = className;
16+
}
17+
public void assertEquals(String expected, String actual)
18+
{
19+
try
20+
{
21+
Class<?> clazz = ObjectUtils.loadClass(className);
22+
Method assertEquals = clazz.getMethod("assertEquals", Object.class, Object.class);
23+
assertEquals.invoke(null, expected, actual);
1524
}
16-
17-
public void assertEquals(String expected, String actual) {
18-
try {
19-
Class<?> clazz = ObjectUtils.loadClass(className);
20-
Method assertEquals = clazz.getMethod("assertEquals", Object.class, Object.class);
21-
assertEquals.invoke(null, expected, actual);
22-
} catch(InvocationTargetException exception) {
23-
throw ObjectUtils.throwAsError(exception.getTargetException());
24-
}catch (Throwable throwable) {
25-
throw ObjectUtils.throwAsError(throwable);
26-
}
25+
catch (InvocationTargetException exception)
26+
{
27+
throw ObjectUtils.throwAsError(exception.getTargetException());
2728
}
28-
29-
@Override
30-
public void report(String received, String approved) {
31-
String aText = new File(approved).exists() ? FileUtils.readFile(approved) : "";
32-
String rText = FileUtils.readFile(received);
33-
String approveCommand = "To approve run : " + ClipboardReporter.getAcceptApprovalText(received, approved);
34-
System.out.println(approveCommand);
35-
assertEquals(aText, rText);
36-
}
37-
38-
@Override
39-
public boolean isWorkingInThisEnvironment(String forFile) {
40-
boolean present = ObjectUtils.isClassPresent(className);
41-
return present && GenericDiffReporter.isFileExtensionValid(forFile, GenericDiffReporter.TEXT_FILE_EXTENSIONS);
29+
catch (Throwable throwable)
30+
{
31+
throw ObjectUtils.throwAsError(throwable);
4232
}
33+
}
34+
@Override
35+
public void report(String received, String approved)
36+
{
37+
String aText = new File(approved).exists() ? FileUtils.readFile(approved) : "";
38+
String rText = FileUtils.readFile(received);
39+
String approveCommand = "To approve run : " + ClipboardReporter.getAcceptApprovalText(received, approved);
40+
System.out.println(approveCommand);
41+
assertEquals(aText, rText);
42+
}
43+
@Override
44+
public boolean isWorkingInThisEnvironment(String forFile)
45+
{
46+
boolean present = ObjectUtils.isClassPresent(className);
47+
return present && GenericDiffReporter.isFileExtensionValid(forFile, GenericDiffReporter.TEXT_FILE_EXTENSIONS);
48+
}
4349
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.approvaltests.reporters;
22

3-
public class Junit3Reporter extends AbstractJUnitReporter {
4-
5-
public Junit3Reporter() {
6-
super("junit.framework.Assert");
7-
}
3+
public class Junit3Reporter extends AbstractJUnitReporter
4+
{
5+
public Junit3Reporter()
6+
{
7+
super("junit.framework.Assert");
8+
}
89
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.approvaltests.reporters;
22

3-
public class Junit4Reporter extends AbstractJUnitReporter {
4-
5-
public Junit4Reporter() {
6-
super("org.junit.Assert");
7-
}
3+
public class Junit4Reporter extends AbstractJUnitReporter
4+
{
5+
public Junit4Reporter()
6+
{
7+
super("org.junit.Assert");
8+
}
89
}
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.approvaltests.reporters;
22

3-
public class Junit5Reporter extends AbstractJUnitReporter {
4-
5-
public Junit5Reporter() {
6-
super("org.junit.jupiter.api.Assertions");
7-
}
3+
public class Junit5Reporter extends AbstractJUnitReporter
4+
{
5+
public Junit5Reporter()
6+
{
7+
super("org.junit.jupiter.api.Assertions");
8+
}
89
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package org.approvaltests.reporters;
22

3-
43
public class JunitReporter extends FirstWorkingReporter
54
{
65
public static final JunitReporter INSTANCE = new JunitReporter();
76
public JunitReporter()
87
{
98
super(new Junit5Reporter(), new Junit4Reporter(), new Junit3Reporter());
109
}
11-
1210
}

0 commit comments

Comments
 (0)