Skip to content

Commit

Permalink
added automatic tests for Data and Value with generics
Browse files Browse the repository at this point in the history
  • Loading branch information
Michail Plushnikov committed Mar 25, 2016
1 parent b7c8c86 commit 8b30698
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 20 deletions.
4 changes: 4 additions & 0 deletions src/test/java/de/plushnikov/lombok/tests/DataTest.java
Expand Up @@ -45,4 +45,8 @@ public void testDataStaticConstructor() throws IOException {
// Test for issue #9
doTest();
}

public void testDataWithGeneric176() throws IOException {
doTest();
}
}
4 changes: 4 additions & 0 deletions src/test/java/de/plushnikov/lombok/tests/ValueTest.java
Expand Up @@ -51,4 +51,8 @@ public void testValueAndWither() throws IOException {
public void testValueAndWitherAndRequiredConstructor() throws IOException {
doTest();
}

public void testValueWithGeneric176() throws IOException {
doTest();
}
}
@@ -1,28 +1,30 @@
package de.plushnikov.data;


import lombok.Data;

@Data
public class DataWithGenerics<T> {
@Data(staticConstructor = "of")
public class DataWithGeneric176<T> {

private final T command;
private final Runnable callback;

public static void main(String[] args) {
DataWithGenerics<Integer> test = new DataWithGenerics<Integer>(123, new Runnable() {
DataWithGeneric176<Integer> test = new DataWithGeneric176<Integer>(123, new Runnable() {
@Override
public void run() {
System.out.println("Run");
}
});

test.getCallback();
test.getCommand();
System.out.println(test.getCommand());

DataWithGenerics<String> foo = new DataWithGenerics<String>("fooqwqww", new Runnable() {
DataWithGeneric176<String> foo = DataWithGeneric176.of("fooqwqww", new Runnable() {
public void run() {
}
});

foo.getCallback();
System.out.println(foo.getCommand());
}
}
14 changes: 0 additions & 14 deletions test-manual/src/main/java/de/plushnikov/value/Issue176.java

This file was deleted.

@@ -0,0 +1,14 @@
package de.plushnikov.value;

import lombok.Value;

@Value(staticConstructor = "of")
public class ValueWithGeneric176<T> {
private T name;
private int count;

public static void main(String[] args) {
ValueWithGeneric176<String> valueObject = ValueWithGeneric176.of("thing1", 10);
System.out.println(valueObject);
}
}
75 changes: 75 additions & 0 deletions testData/after/DataWithGeneric176.java
@@ -0,0 +1,75 @@
public class DataWithGeneric176<T> {

private final T command;
private final Runnable callback;

@java.beans.ConstructorProperties({"command", "callback"})
private DataWithGeneric176(T command, Runnable callback) {
this.command = command;
this.callback = callback;
}

public static void main(String[] args) {
DataWithGeneric176<Integer> test = new DataWithGeneric176<Integer>(123, new Runnable() {
@Override
public void run() {
System.out.println("Run");
}
});

test.getCallback();
System.out.println(test.getCommand());

DataWithGeneric176<String> foo = DataWithGeneric176.of("fooqwqww", new Runnable() {
public void run() {
}
});

foo.getCallback();
System.out.println(foo.getCommand());
}

public static <T> DataWithGeneric176<T> of(T command, Runnable callback) {
return new DataWithGeneric176<T>(command, callback);
}

public T getCommand() {
return this.command;
}

public Runnable getCallback() {
return this.callback;
}

public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof DataWithGeneric176)) return false;
final DataWithGeneric176 other = (DataWithGeneric176) o;
if (!other.canEqual((Object) this)) return false;
final Object this$command = this.command;
final Object other$command = other.command;
if (this$command == null ? other$command != null : !this$command.equals(other$command)) return false;
final Object this$callback = this.callback;
final Object other$callback = other.callback;
if (this$callback == null ? other$callback != null : !this$callback.equals(other$callback)) return false;
return true;
}

public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $command = this.command;
result = result * PRIME + ($command == null ? 0 : $command.hashCode());
final Object $callback = this.callback;
result = result * PRIME + ($callback == null ? 0 : $callback.hashCode());
return result;
}

protected boolean canEqual(Object other) {
return other instanceof DataWithGeneric176;
}

public String toString() {
return "DataWithGeneric176(command=" + this.command + ", callback=" + this.callback + ")";
}
}
51 changes: 51 additions & 0 deletions testData/after/ValueWithGeneric176.java
@@ -0,0 +1,51 @@
public class ValueWithGeneric176<T> {
private T name;
private int count;

@java.beans.ConstructorProperties({"name", "count"})
private ValueWithGeneric176(T name, int count) {
this.name = name;
this.count = count;
}

public static void main(String[] args) {
ValueWithGeneric176<String> valueObject = ValueWithGeneric176.of("thing1", 10);
System.out.println(valueObject);
}

public static <T> ValueWithGeneric176<T> of(T name, int count) {
return new ValueWithGeneric176<T>(name, count);
}

public T getName() {
return this.name;
}

public int getCount() {
return this.count;
}

public boolean equals(Object o) {
if (o == this) return true;
if (!(o instanceof ValueWithGeneric176)) return false;
final ValueWithGeneric176 other = (ValueWithGeneric176) o;
final Object this$name = this.name;
final Object other$name = other.name;
if (this$name == null ? other$name != null : !this$name.equals(other$name)) return false;
if (this.count != other.count) return false;
return true;
}

public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $name = this.name;
result = result * PRIME + ($name == null ? 0 : $name.hashCode());
result = result * PRIME + this.count;
return result;
}

public String toString() {
return "ValueWithGeneric176(name=" + this.name + ", count=" + this.count + ")";
}
}
28 changes: 28 additions & 0 deletions testData/before/DataWithGeneric176.java
@@ -0,0 +1,28 @@
import lombok.Data;

@Data(staticConstructor = "of")
public class DataWithGeneric176<T> {

private final T command;
private final Runnable callback;

public static void main(String[] args) {
DataWithGeneric176<Integer> test = new DataWithGeneric176<Integer>(123, new Runnable() {
@Override
public void run() {
System.out.println("Run");
}
});

test.getCallback();
System.out.println(test.getCommand());

DataWithGeneric176<String> foo = DataWithGeneric176.of("fooqwqww", new Runnable() {
public void run() {
}
});

foo.getCallback();
System.out.println(foo.getCommand());
}
}
12 changes: 12 additions & 0 deletions testData/before/ValueWithGeneric176.java
@@ -0,0 +1,12 @@
import lombok.Value;

@Value(staticConstructor = "of")
public class ValueWithGeneric176<T> {
private T name;
private int count;

public static void main(String[] args) {
ValueWithGeneric176<String> valueObject = ValueWithGeneric176.of("thing1", 10);
System.out.println(valueObject);
}
}

0 comments on commit 8b30698

Please sign in to comment.