I am introducing Junit tests in one of our projects but unfortunately am getting a null pointer exception but I can’t tell where is it thrown, when trying to debug the debugger does not stop in my break point. I am testing a spring boot application
Can you assist I am not familiar with gradle maybe I missed a certain config, below is my gradle file
buildscript {
ext {
springBootVersion = '2.2.11.RELEASE'
}
repositories {
mavenCentral()
maven {
url "https://artifacts.company.com/artifactory/appsmav-main-maven-local/"
credentials {
username "${artifactory_user}"
password "${artifactory_password}"
}
}
maven {
url "https://plugins.gradle.org/m2/"
}
// flatDir {
// dirs '/Users/pabu/workspaces/intellij/companyikat7/PlantumlPlugin/build/libs'
// }
}
repositories { flatDir name: 'libs', dirs: "../build/libs" }
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-RC3'
classpath 'org.reflections:reflections:0.9.11'
classpath 'io.company.gradle.plugins:PlantumlPlugin:1.0.7'
classpath "gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:2.2.4"
classpath "gradle.plugin.com.github.viswaramamoorthy:gradle-util-plugins:0.1.0-RELEASE"
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
apply plugin: 'org.junit.platform.gradle.plugin'
apply plugin: 'io.company.gradle.plugins.plantuml'
apply plugin: 'com.gorylenko.gradle-git-properties'
apply plugin: "com.github.ManifestClasspath"
group = 'io.company'
version = '0.0.2'
sourceCompatibility = "11"
repositories {
jcenter()
mavenCentral()
maven {
url "https://artifacts.company.com/artifactory/appsmav-main-maven-local/"
credentials {
username "${artifactory_user}"
password "${artifactory_password}"
}
}
}
springBoot {
buildInfo {
properties {
artifact = 'company-core-service'
name = 'company'
}
}
}
configurations {
providedRuntime
compile.exclude module: 'slf4j-simple'
compile.exclude module: "spring-boot-starter-tomcat"
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-jersey')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-jetty')
compileOnly('org.springframework.boot:spring-boot-devtools')
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
// https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-freemarker
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-freemarker', version: '2.5.3'
implementation 'io.micrometer:micrometer-core:1.5.7'
implementation 'io.micrometer:micrometer-registry-prometheus:1.5.7'
implementation 'io.sentry:sentry-spring-boot-starter:3.2.0'
implementation 'io.sentry:sentry-logback:3.2.0'
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.8.0'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.8.0'
compile group: 'com.unboundid', name: 'unboundid-ldapsdk', version: '4.0.0'
runtime('org.postgresql:postgresql')
compile('io.company.commons:commons-utils:1.+') {
exclude group: 'org.slf4j'
}
compile('io.company.commons:commons-api:1.3.0') {
exclude group: 'org.slf4j'
}
// https://mvnrepository.com/artifact/org.springframework.retry/spring-retry
compile group: 'org.springframework.retry', name: 'spring-retry', version: '1.3.0'
// Azure Notification Hub SDK
compile group: 'com.windowsazure', name: 'Notification-Hubs-java-sdk', version: '0.1.0'
// https://mvnrepository.com/artifact/javax.json/javax.json-api
compile group: 'javax.json', name: 'javax.json-api', version: '1.1.4'
// https://mvnrepository.com/artifact/org.glassfish/javax.json
compile group: 'org.glassfish', name: 'javax.json', version: '1.1.4'
implementation 'com.sun.mail:javax.mail:1.6.2'
// compile project(":commons-api-local")
compile('io.company.commons:commons-io:1.3.0') {
exclude group: 'org.slf4j'
}
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'io.company.commons', name: 'commons-jwt', version: '1.0.8'
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
// https://projectlombok.org
compileOnly 'org.projectlombok:lombok:1.18.4'
annotationProcessor 'org.projectlombok:lombok:1.18.4'
testImplementation('org.junit.jupiter:junit-jupiter:5.5.1')
}
test {
useJUnitPlatform {
excludeTags "integration"
}
testLogging.showStandardStreams(true);
testLogging {
events "passed", "skipped", "failed"
showExceptions true
exceptionFormat "full"
showCauses true
showStackTraces true
}
}
In the log below I can’t tell where is the NullPointerException thrown
16:38:55.075 [main] DEBUG org.springframework.ui.freemarker.SpringTemplateLoader - Looking for FreeMarker template with name [DisruptionOverviewBody_en.ftlh]
16:38:55.076 [main] DEBUG org.springframework.ui.freemarker.SpringTemplateLoader - Looking for FreeMarker template with name [DisruptionOverviewBody.ftlh]
Failures (1):
JUnit Jupiter:DisruptionEventControllerTest:shouldCreateNewDisruptionEvent()
MethodSource [className = 'ui.controller.DisruptionEventControllerTest', methodName = 'shouldCreateNewDisruptionEvent', methodParameterTypes = '']
=> java.lang.NullPointerException
Test run finished after 1639 ms