I have following code in one of my tests:
List<Long> wordList = wordService.listAll().stream()
.map(StudiedWord::getId)
.collect(Collectors.toList());
StudiedWord is a POJO with Lombok:
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
public class StudiedWord extends AbstractModelClass {
private String text;
private String translation;
private WordStage stage;
private String image;
private String sound;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
abstract class AbstractModelClass implements ModelObject {
@Id
@GeneratedValue
private Long id;
}
I can run tests from IntelliJ IDEA and everything is OK. I can run tests manually from a terminal using Gradle and again everything is OK.
But on Travis I constantly get following error:
WordSetControllerTest > deleteWordSet FAILED
java.lang.IllegalAccessError at WordSetControllerTest.java:255
The 255th line is the line with map statement and method reference. If I replace method reference with lambda expression (studiedWord -> studiedWord.getId()
) then again everything is fine.
Here is content of my .travis.yml:
language: java
jdk:
- oraclejdk8
Here is an example of my tests structure:
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class)
@WebAppConfiguration
@Slf4j
public abstract class MockMvcBase {
/// common fields and methods for mock mvc tests
}
@Transactional
public class WordSetControllerTest extends MockMvcBase {
@Autowired
private WordService wordService;
@Autowired
private WordSetService wordSetService;
// other methods
@Test
public void deleteWordSetById() throws Exception {
// test logic
List<Long> wordList = wordService.listAll().stream()
.map(StudiedWord::getId)
.collect(Collectors.toList());
// assertions
}
}
I have other tests where I use method references for other Lombok-generated methods and they work fine.
Is it problems with my Travis configuration or what am I missing?