I'm attempting to run a simple junit test from gradle on an proof of concept class I've compiled and deployed to aws lambda. The class Auth.java
takes a POJO with a single property email
. It compiles fine on it's own and works on aws. However, when I run:
gradle build
I receive the following error:
Auth.java:6: error: cannot find symbol
System.out.println(payload.email);
symbol: variable email
location: variable payload of type Object
1 error
:compileJava FAILED
If I System.out.println(payload.email);
from within TestAuth.java
I can access the object's property no problem. Am I failing to grasp some key java or gradle concept here? I've refactored this things 5 different ways and still, I always receive this cannot find symbol error. Anybody have any ideas? Here's my simplified code.
./src/main/java/Auth.java
package works.valt.api;
public class Auth {
public Auth(Object payload) {
System.out.println(payload.email);
}
}
./src/test/java/TestAuth.java
import org.junit.Test;
import org.junit.Before;
import static org.junit.Assert.assertEquals;
import works.valt.api.Auth;
public class TestAuth {
public class Payload {
public String email = "[email protected]";
}
private Payload payload;
// create payload
@Before
public void setUp() {
this.payload = new Payload();
}
@Test
public void testResponse() {
Auth response = new Auth(this.payload);
}
}
build.gradle
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.12'
}
test {
testLogging.showStandardStreams = true
}
task buildZip(type: Zip) {
from compileJava
from processResources
into('lib') {
from configurations.runtime
}
}
build.dependsOn buildZip