Skip to content

Commit

Permalink
add tests for summarize and no args constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
timo-a committed Apr 9, 2021
1 parent 8e666a0 commit df404be
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 8 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,5 @@ while read f; do lomboker mark setter "$f"; done < fuzzySetters.txt;
- test required for push
- build jars
- getter setter shall have their own line
- toString
- noArgsConstructor
- summarize getter/setter
- test noArgsConstructor
- test summarize getter/setter
6 changes: 2 additions & 4 deletions app/src/main/java/de/lomboker/app/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
subcommands = {
CounterApp.class,
Reduce.class,
Mark.class,
ReduceFuzzyEaH.class,
ReduceFuzzyToString.class
})
Mark.class
})
public class App implements Runnable {
public static void main(String[] args) {
new CommandLine(new App()).execute(args);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/de/lomboker/app/Reduce.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
subcommands = {
ReduceGetter.class,
ReduceSetter.class,
ReduceFuzzyEaH.class,
ReduceFuzzyToString.class,
ReduceNoArgsConstructor.class},
description = "no options or positional parameters")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import static de.lomboker.lib.NoArgsConstructor.reduceNoArgsConstructor;
import static de.lomboker.lib.TrivialGetters.reduceGetters;

@Command(name = "constructor", description = "reduce no args constructor")
@Command(name = "no-args-constructor", description = "reduce no args constructor")
public class ReduceNoArgsConstructor implements Runnable {

@Parameters(index = "0")
Expand Down
21 changes: 21 additions & 0 deletions lib/src/test/java/de/lomboker/lib/ReduceNoArgsConstructorTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package de.lomboker.lib;

import org.junit.jupiter.api.Test;

import java.io.IOException;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class ReduceNoArgsConstructorTest extends FileTest {

@Test
public void testFuzzyToString() throws IOException {
String fileName = "Fuzzy/Constructor/NoArgs.java";
String fileNameRef = "Fuzzy/Constructor/NoArgs.reduced.java";
String input = readFile(fileName);
String expected = readFile(fileNameRef);

assertEquals(expected, NoArgsConstructor.reduceNoArgsConstructor(input));
}

}
31 changes: 31 additions & 0 deletions lib/src/test/java/de/lomboker/lib/SummarizeGetterSetterTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package de.lomboker.lib;

import org.junit.jupiter.api.Test;

import java.io.IOException;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class SummarizeGetterSetterTest extends FileTest {

@Test
public void shouldSummarizeAllGettersWhenAllFieldsHaveGetters() throws IOException {
String fileName = "Summarize/gs/AllGetterSomeSetter.java";
String fileNameRef = "Summarize/gs/AllGetterSomeSetter.reduced.java";
String input = readFile(fileName);
String expected = readFile(fileNameRef);

assertEquals(expected, SummarizeGetterSetter.summarizeGetters(input));
assertEquals(input, SummarizeGetterSetter.summarizeSetters(input));
}

@Test
public void shouldNotSummarizeAllSettersWhenNotAllFieldsHaveSetters() throws IOException {
String fileName = "Summarize/gs/AllGetterSomeSetter.java";
String fileNameRef = "Summarize/gs/AllGetterSomeSetter.reduced.java";
String input = readFile(fileName);

assertEquals(input, SummarizeGetterSetter.summarizeSetters(input));
}

}
7 changes: 7 additions & 0 deletions lib/src/test/resources/Fuzzy/Constructor/NoArgs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class A {

public A() {

}

}
6 changes: 6 additions & 0 deletions lib/src/test/resources/Fuzzy/Constructor/NoArgs.reduced.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import lombok.NoArgsConstructor;

@NoArgsConstructor
class A {

}
14 changes: 14 additions & 0 deletions lib/src/test/resources/Summarize/gs/AllGetterSomeSetter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class A {

@Getter
@Setter
int a;

@Getter
@Setter
String b;

@Getter
boolean c;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@Getter
class A {


@Setter
int a;


@Setter
String b;

boolean c;

}

0 comments on commit df404be

Please sign in to comment.