diff --git a/src/main/java/fr/yodamad/svn2git/Svn2GitApp.java b/src/main/java/fr/yodamad/svn2git/Svn2GitApp.java
index d46d14e0..258fc79a 100644
--- a/src/main/java/fr/yodamad/svn2git/Svn2GitApp.java
+++ b/src/main/java/fr/yodamad/svn2git/Svn2GitApp.java
@@ -4,7 +4,7 @@
import fr.yodamad.svn2git.config.ApplicationProperties;
import fr.yodamad.svn2git.config.DefaultProfileUtil;
-import io.github.jhipster.config.JHipsterConstants;
+import tech.jhipster.config.JHipsterConstants;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
diff --git a/src/main/java/fr/yodamad/svn2git/aop/logging/LoggingAspect.java b/src/main/java/fr/yodamad/svn2git/aop/logging/LoggingAspect.java
index 2504d4c8..6e9d2d15 100644
--- a/src/main/java/fr/yodamad/svn2git/aop/logging/LoggingAspect.java
+++ b/src/main/java/fr/yodamad/svn2git/aop/logging/LoggingAspect.java
@@ -1,6 +1,6 @@
package fr.yodamad.svn2git.aop.logging;
-import io.github.jhipster.config.JHipsterConstants;
+import tech.jhipster.config.JHipsterConstants;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
diff --git a/src/main/java/fr/yodamad/svn2git/config/ApplicationProperties.java b/src/main/java/fr/yodamad/svn2git/config/ApplicationProperties.java
index 8c328434..472e507a 100644
--- a/src/main/java/fr/yodamad/svn2git/config/ApplicationProperties.java
+++ b/src/main/java/fr/yodamad/svn2git/config/ApplicationProperties.java
@@ -8,7 +8,7 @@
* Properties specific to Svn 2 Git.
*
* Properties are configured in the application.yml file.
- * See {@link io.github.jhipster.config.JHipsterProperties} for a good example.
+ * See {@link tech.jhipster.config.JHipsterProperties} for a good example.
*/
@ConfigurationProperties(prefix = "application", ignoreUnknownFields = false)
public class ApplicationProperties {
diff --git a/src/main/java/fr/yodamad/svn2git/config/AsyncConfiguration.java b/src/main/java/fr/yodamad/svn2git/config/AsyncConfiguration.java
index 82a29dae..9b5dd98c 100644
--- a/src/main/java/fr/yodamad/svn2git/config/AsyncConfiguration.java
+++ b/src/main/java/fr/yodamad/svn2git/config/AsyncConfiguration.java
@@ -1,11 +1,12 @@
package fr.yodamad.svn2git.config;
-import io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor;
-import io.github.jhipster.config.JHipsterProperties;
+import tech.jhipster.async.ExceptionHandlingAsyncTaskExecutor;
+import tech.jhipster.config.JHipsterProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
@@ -31,6 +32,7 @@ public class AsyncConfiguration implements AsyncConfigurer, SchedulingConfigurer
@Override
@Bean(name = "taskExecutor")
+ @Qualifier(value = "taskExecutor")
public Executor getAsyncExecutor() {
log.debug("Creating Async Task Executor");
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
@@ -45,7 +47,7 @@ public Executor getAsyncExecutor() {
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return new SimpleAsyncUncaughtExceptionHandler();
}
-
+
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(scheduledTaskExecutor());
diff --git a/src/main/java/fr/yodamad/svn2git/config/DatabaseConfiguration.java b/src/main/java/fr/yodamad/svn2git/config/DatabaseConfiguration.java
index 221a31f9..518fb236 100644
--- a/src/main/java/fr/yodamad/svn2git/config/DatabaseConfiguration.java
+++ b/src/main/java/fr/yodamad/svn2git/config/DatabaseConfiguration.java
@@ -1,7 +1,7 @@
package fr.yodamad.svn2git.config;
-import io.github.jhipster.config.JHipsterConstants;
-import io.github.jhipster.config.h2.H2ConfigurationHelper;
+import tech.jhipster.config.JHipsterConstants;
+import tech.jhipster.config.h2.H2ConfigurationHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
diff --git a/src/main/java/fr/yodamad/svn2git/config/DefaultProfileUtil.java b/src/main/java/fr/yodamad/svn2git/config/DefaultProfileUtil.java
index 3c2eccbe..cd8f1f35 100644
--- a/src/main/java/fr/yodamad/svn2git/config/DefaultProfileUtil.java
+++ b/src/main/java/fr/yodamad/svn2git/config/DefaultProfileUtil.java
@@ -1,6 +1,6 @@
package fr.yodamad.svn2git.config;
-import io.github.jhipster.config.JHipsterConstants;
+import tech.jhipster.config.JHipsterConstants;
import org.springframework.boot.SpringApplication;
import org.springframework.core.env.Environment;
diff --git a/src/main/java/fr/yodamad/svn2git/config/LiquibaseConfiguration.java b/src/main/java/fr/yodamad/svn2git/config/LiquibaseConfiguration.java
index 88a14158..2513206d 100644
--- a/src/main/java/fr/yodamad/svn2git/config/LiquibaseConfiguration.java
+++ b/src/main/java/fr/yodamad/svn2git/config/LiquibaseConfiguration.java
@@ -1,21 +1,26 @@
package fr.yodamad.svn2git.config;
-import javax.sql.DataSource;
-
+import liquibase.integration.spring.SpringLiquibase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
+import org.springframework.boot.autoconfigure.liquibase.LiquibaseDataSource;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.DependsOn;
import org.springframework.core.env.Environment;
-import org.springframework.core.task.TaskExecutor;
+import org.springframework.core.env.Profiles;
+import tech.jhipster.config.JHipsterConstants;
+import tech.jhipster.config.liquibase.SpringLiquibaseUtil;
-import io.github.jhipster.config.JHipsterConstants;
-import io.github.jhipster.config.liquibase.AsyncSpringLiquibase;
-import liquibase.integration.spring.SpringLiquibase;
+import javax.sql.DataSource;
+import java.util.concurrent.Executor;
@Configuration
+@DependsOn("asyncConfiguration")
public class LiquibaseConfiguration {
private final Logger log = LoggerFactory.getLogger(LiquibaseConfiguration.class);
@@ -28,18 +33,36 @@ public LiquibaseConfiguration(Environment env) {
}
@Bean
- public SpringLiquibase liquibase(@Qualifier("taskExecutor") TaskExecutor taskExecutor,
- DataSource dataSource, LiquibaseProperties liquibaseProperties) {
-
- // Use liquibase.integration.spring.SpringLiquibase if you don't want Liquibase to start asynchronously
- SpringLiquibase liquibase = new AsyncSpringLiquibase(taskExecutor, env);
- liquibase.setDataSource(dataSource);
+ public SpringLiquibase liquibase(
+ @Qualifier("taskExecutor") Executor executor,
+ @LiquibaseDataSource ObjectProvider liquibaseDataSource,
+ LiquibaseProperties liquibaseProperties,
+ ObjectProvider dataSource,
+ DataSourceProperties dataSourceProperties
+ ) {
+ // If you don't want Liquibase to start asynchronously, substitute by this:
+ // SpringLiquibase liquibase = SpringLiquibaseUtil.createSpringLiquibase(liquibaseDataSource.getIfAvailable(), liquibaseProperties, dataSource.getIfUnique(), dataSourceProperties);
+ SpringLiquibase liquibase = SpringLiquibaseUtil.createAsyncSpringLiquibase(
+ this.env,
+ executor,
+ liquibaseDataSource.getIfAvailable(),
+ liquibaseProperties,
+ dataSource.getIfUnique(),
+ dataSourceProperties
+ );
liquibase.setChangeLog("classpath:config/liquibase/master.xml");
liquibase.setContexts(liquibaseProperties.getContexts());
liquibase.setDefaultSchema(liquibaseProperties.getDefaultSchema());
+ liquibase.setLiquibaseSchema(liquibaseProperties.getLiquibaseSchema());
+ liquibase.setLiquibaseTablespace(liquibaseProperties.getLiquibaseTablespace());
+ liquibase.setDatabaseChangeLogLockTable(liquibaseProperties.getDatabaseChangeLogLockTable());
+ liquibase.setDatabaseChangeLogTable(liquibaseProperties.getDatabaseChangeLogTable());
liquibase.setDropFirst(liquibaseProperties.isDropFirst());
+ liquibase.setLabels(liquibaseProperties.getLabels());
liquibase.setChangeLogParameters(liquibaseProperties.getParameters());
- if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_NO_LIQUIBASE)) {
+ liquibase.setRollbackFile(liquibaseProperties.getRollbackFile());
+ liquibase.setTestRollbackOnUpdate(liquibaseProperties.isTestRollbackOnUpdate());
+ if (env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_NO_LIQUIBASE))) {
liquibase.setShouldRun(false);
} else {
liquibase.setShouldRun(liquibaseProperties.isEnabled());
diff --git a/src/main/java/fr/yodamad/svn2git/config/LocaleConfiguration.java b/src/main/java/fr/yodamad/svn2git/config/LocaleConfiguration.java
index 97401734..d977e97c 100644
--- a/src/main/java/fr/yodamad/svn2git/config/LocaleConfiguration.java
+++ b/src/main/java/fr/yodamad/svn2git/config/LocaleConfiguration.java
@@ -1,6 +1,6 @@
package fr.yodamad.svn2git.config;
-import io.github.jhipster.config.locale.AngularCookieLocaleResolver;
+import tech.jhipster.config.locale.AngularCookieLocaleResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
diff --git a/src/main/java/fr/yodamad/svn2git/config/LoggingAspectConfiguration.java b/src/main/java/fr/yodamad/svn2git/config/LoggingAspectConfiguration.java
index 25b06691..79a812d2 100644
--- a/src/main/java/fr/yodamad/svn2git/config/LoggingAspectConfiguration.java
+++ b/src/main/java/fr/yodamad/svn2git/config/LoggingAspectConfiguration.java
@@ -2,7 +2,7 @@
import fr.yodamad.svn2git.aop.logging.LoggingAspect;
-import io.github.jhipster.config.JHipsterConstants;
+import tech.jhipster.config.JHipsterConstants;
import org.springframework.context.annotation.*;
import org.springframework.core.env.Environment;
diff --git a/src/main/java/fr/yodamad/svn2git/config/LoggingConfiguration.java b/src/main/java/fr/yodamad/svn2git/config/LoggingConfiguration.java
index 4a099919..9e4f9b2c 100644
--- a/src/main/java/fr/yodamad/svn2git/config/LoggingConfiguration.java
+++ b/src/main/java/fr/yodamad/svn2git/config/LoggingConfiguration.java
@@ -1,27 +1,18 @@
package fr.yodamad.svn2git.config;
-import java.net.InetSocketAddress;
-import java.util.Iterator;
-
-import io.github.jhipster.config.JHipsterProperties;
-
-import ch.qos.logback.classic.AsyncAppender;
-import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.boolex.OnMarkerEvaluator;
import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.classic.spi.LoggerContextListener;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.filter.EvaluatorFilter;
-import ch.qos.logback.core.spi.ContextAwareBase;
import ch.qos.logback.core.spi.FilterReply;
-import net.logstash.logback.appender.LogstashTcpSocketAppender;
-import net.logstash.logback.encoder.LogstashEncoder;
-import net.logstash.logback.stacktrace.ShortenedThrowableConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
+import tech.jhipster.config.JHipsterProperties;
+
+import java.util.Iterator;
@Configuration
public class LoggingConfiguration {
@@ -45,53 +36,6 @@ public LoggingConfiguration(@Value("${spring.application.name}") String appName,
this.appName = appName;
this.serverPort = serverPort;
this.jHipsterProperties = jHipsterProperties;
- if (jHipsterProperties.getLogging().getLogstash().isEnabled()) {
- addLogstashAppender(context);
- addContextListener(context);
- }
- if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
- setMetricsMarkerLogbackFilter(context);
- }
- }
-
- private void addContextListener(LoggerContext context) {
- LogbackLoggerContextListener loggerContextListener = new LogbackLoggerContextListener();
- loggerContextListener.setContext(context);
- context.addListener(loggerContextListener);
- }
-
- private void addLogstashAppender(LoggerContext context) {
- log.info("Initializing Logstash logging");
-
- LogstashTcpSocketAppender logstashAppender = new LogstashTcpSocketAppender();
- logstashAppender.setName(LOGSTASH_APPENDER_NAME);
- logstashAppender.setContext(context);
- String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"}";
-
- // More documentation is available at: https://github.com/logstash/logstash-logback-encoder
- LogstashEncoder logstashEncoder = new LogstashEncoder();
- // Set the Logstash appender config from JHipster properties
- logstashEncoder.setCustomFields(customFields);
- // Set the Logstash appender config from JHipster properties
- logstashAppender.addDestinations(new InetSocketAddress(jHipsterProperties.getLogging().getLogstash().getHost(), jHipsterProperties.getLogging().getLogstash().getPort()));
-
- ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
- throwableConverter.setRootCauseFirst(true);
- logstashEncoder.setThrowableConverter(throwableConverter);
- logstashEncoder.setCustomFields(customFields);
-
- logstashAppender.setEncoder(logstashEncoder);
- logstashAppender.start();
-
- // Wrap the appender in an Async appender for performance
- AsyncAppender asyncLogstashAppender = new AsyncAppender();
- asyncLogstashAppender.setContext(context);
- asyncLogstashAppender.setName(ASYNC_LOGSTASH_APPENDER_NAME);
- asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize());
- asyncLogstashAppender.addAppender(logstashAppender);
- asyncLogstashAppender.start();
-
- context.getLogger("ROOT").addAppender(asyncLogstashAppender);
}
// Configure a log filter to remove "metrics" logs from all appenders except the "LOGSTASH" appender
@@ -119,38 +63,4 @@ private void setMetricsMarkerLogbackFilter(LoggerContext context) {
}
}
}
-
- /**
- * Logback configuration is achieved by configuration file and API.
- * When configuration file change is detected, the configuration is reset.
- * This listener ensures that the programmatic configuration is also re-applied after reset.
- */
- class LogbackLoggerContextListener extends ContextAwareBase implements LoggerContextListener {
-
- @Override
- public boolean isResetResistant() {
- return true;
- }
-
- @Override
- public void onStart(LoggerContext context) {
- addLogstashAppender(context);
- }
-
- @Override
- public void onReset(LoggerContext context) {
- addLogstashAppender(context);
- }
-
- @Override
- public void onStop(LoggerContext context) {
- // Nothing to do.
- }
-
- @Override
- public void onLevelChange(ch.qos.logback.classic.Logger logger, Level level) {
- // Nothing to do.
- }
- }
-
}
diff --git a/src/main/java/fr/yodamad/svn2git/config/MetricsConfiguration.java b/src/main/java/fr/yodamad/svn2git/config/MetricsConfiguration.java
index 13ac33b3..a631086d 100644
--- a/src/main/java/fr/yodamad/svn2git/config/MetricsConfiguration.java
+++ b/src/main/java/fr/yodamad/svn2git/config/MetricsConfiguration.java
@@ -2,7 +2,7 @@
import com.codahale.metrics.health.HealthCheckRegistry;
import com.zaxxer.hikari.HikariDataSource;
-import io.github.jhipster.config.JHipsterProperties;
+import tech.jhipster.config.JHipsterProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
diff --git a/src/main/java/fr/yodamad/svn2git/config/WebConfigurer.java b/src/main/java/fr/yodamad/svn2git/config/WebConfigurer.java
index 0842ba7a..f2517307 100644
--- a/src/main/java/fr/yodamad/svn2git/config/WebConfigurer.java
+++ b/src/main/java/fr/yodamad/svn2git/config/WebConfigurer.java
@@ -1,14 +1,8 @@
package fr.yodamad.svn2git.config;
import com.codahale.metrics.servlet.InstrumentedFilter;
-import io.github.jhipster.config.JHipsterConstants;
-import io.github.jhipster.config.JHipsterProperties;
-import io.github.jhipster.config.h2.H2ConfigurationHelper;
-import io.github.jhipster.web.filter.CachingHttpHeadersFilter;
-import io.undertow.UndertowOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.boot.web.server.MimeMappings;
import org.springframework.boot.web.server.WebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
@@ -21,8 +15,15 @@
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
-
-import javax.servlet.*;
+import tech.jhipster.config.JHipsterConstants;
+import tech.jhipster.config.JHipsterProperties;
+import tech.jhipster.config.h2.H2ConfigurationHelper;
+import tech.jhipster.web.filter.CachingHttpHeadersFilter;
+
+import javax.servlet.DispatcherType;
+import javax.servlet.FilterRegistration;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
@@ -30,6 +31,7 @@
import java.util.EnumSet;
import static java.net.URLDecoder.decode;
+import static org.springframework.core.env.Profiles.of;
/**
* Configuration of web application with Servlet 3.0 APIs.
@@ -56,10 +58,10 @@ public void onStartup(ServletContext servletContext) throws ServletException {
}
EnumSet disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC);
initMetrics(servletContext, disps);
- if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
+ if (env.acceptsProfiles(of((JHipsterConstants.SPRING_PROFILE_PRODUCTION)))) {
initCachingHttpHeadersFilter(servletContext, disps);
}
- if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
+ if (env.acceptsProfiles(of((JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)))) {
initH2Console(servletContext);
}
log.info("Web application fully configured");
@@ -74,19 +76,6 @@ public void customize(WebServerFactory server) {
// When running in an IDE or with ./mvnw spring-boot:run, set location of the static web assets.
setLocationForStaticAssets(server);
- /*
- * Enable HTTP/2 for Undertow - https://twitter.com/ankinson/status/829256167700492288
- * HTTP/2 requires HTTPS, so HTTP requests will fallback to HTTP/1.1.
- * See the JHipsterProperties class and your application-*.yml configuration files
- * for more information.
- */
- if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) &&
- server instanceof UndertowServletWebServerFactory) {
-
- ((UndertowServletWebServerFactory) server)
- .addBuilderCustomizers(builder ->
- builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
- }
}
private void setMimeMappings(WebServerFactory server) {
diff --git a/src/main/java/fr/yodamad/svn2git/security/jwt/TokenProvider.java b/src/main/java/fr/yodamad/svn2git/security/jwt/TokenProvider.java
index 95f6b882..ac23309d 100644
--- a/src/main/java/fr/yodamad/svn2git/security/jwt/TokenProvider.java
+++ b/src/main/java/fr/yodamad/svn2git/security/jwt/TokenProvider.java
@@ -16,7 +16,7 @@
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
-import io.github.jhipster.config.JHipsterProperties;
+import tech.jhipster.config.JHipsterProperties;
import io.jsonwebtoken.*;
import io.jsonwebtoken.io.Decoders;
import io.jsonwebtoken.security.Keys;
diff --git a/src/main/java/fr/yodamad/svn2git/service/MailService.java b/src/main/java/fr/yodamad/svn2git/service/MailService.java
index 8f0e6978..e7da9465 100644
--- a/src/main/java/fr/yodamad/svn2git/service/MailService.java
+++ b/src/main/java/fr/yodamad/svn2git/service/MailService.java
@@ -2,7 +2,7 @@
import fr.yodamad.svn2git.domain.User;
-import io.github.jhipster.config.JHipsterProperties;
+import tech.jhipster.config.JHipsterProperties;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
diff --git a/src/main/java/fr/yodamad/svn2git/web/rest/AuditResource.java b/src/main/java/fr/yodamad/svn2git/web/rest/AuditResource.java
index b81d95fb..915fc3bf 100644
--- a/src/main/java/fr/yodamad/svn2git/web/rest/AuditResource.java
+++ b/src/main/java/fr/yodamad/svn2git/web/rest/AuditResource.java
@@ -3,7 +3,7 @@
import fr.yodamad.svn2git.service.AuditEventService;
import fr.yodamad.svn2git.web.rest.util.PaginationUtil;
-import io.github.jhipster.web.util.ResponseUtil;
+import tech.jhipster.web.util.ResponseUtil;
import org.springframework.boot.actuate.audit.AuditEvent;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
diff --git a/src/main/java/fr/yodamad/svn2git/web/rest/StaticExtensionResource.java b/src/main/java/fr/yodamad/svn2git/web/rest/StaticExtensionResource.java
index 291f699f..bc25ee9b 100644
--- a/src/main/java/fr/yodamad/svn2git/web/rest/StaticExtensionResource.java
+++ b/src/main/java/fr/yodamad/svn2git/web/rest/StaticExtensionResource.java
@@ -5,7 +5,7 @@
import fr.yodamad.svn2git.repository.StaticExtensionRepository;
import fr.yodamad.svn2git.web.rest.errors.BadRequestAlertException;
import fr.yodamad.svn2git.web.rest.util.HeaderUtil;
-import io.github.jhipster.web.util.ResponseUtil;
+import tech.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
diff --git a/src/main/java/fr/yodamad/svn2git/web/rest/StaticMappingResource.java b/src/main/java/fr/yodamad/svn2git/web/rest/StaticMappingResource.java
index cda405aa..3d14bf8b 100644
--- a/src/main/java/fr/yodamad/svn2git/web/rest/StaticMappingResource.java
+++ b/src/main/java/fr/yodamad/svn2git/web/rest/StaticMappingResource.java
@@ -5,7 +5,7 @@
import fr.yodamad.svn2git.service.StaticMappingService;
import fr.yodamad.svn2git.web.rest.errors.BadRequestAlertException;
import fr.yodamad.svn2git.web.rest.util.HeaderUtil;
-import io.github.jhipster.web.util.ResponseUtil;
+import tech.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
diff --git a/src/main/java/fr/yodamad/svn2git/web/rest/UserResource.java b/src/main/java/fr/yodamad/svn2git/web/rest/UserResource.java
index 2f2df5d0..8149d03f 100644
--- a/src/main/java/fr/yodamad/svn2git/web/rest/UserResource.java
+++ b/src/main/java/fr/yodamad/svn2git/web/rest/UserResource.java
@@ -13,7 +13,7 @@
import fr.yodamad.svn2git.web.rest.util.HeaderUtil;
import fr.yodamad.svn2git.web.rest.util.PaginationUtil;
import com.codahale.metrics.annotation.Timed;
-import io.github.jhipster.web.util.ResponseUtil;
+import tech.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/kotlin/fr/yodamad/svn2git/service/GitManager.kt b/src/main/kotlin/fr/yodamad/svn2git/service/GitManager.kt
index 5e9138b0..38d121af 100644
--- a/src/main/kotlin/fr/yodamad/svn2git/service/GitManager.kt
+++ b/src/main/kotlin/fr/yodamad/svn2git/service/GitManager.kt
@@ -11,7 +11,7 @@ import fr.yodamad.svn2git.io.Shell.execCommand
import fr.yodamad.svn2git.io.Shell.isWindows
import fr.yodamad.svn2git.repository.MappingRepository
import fr.yodamad.svn2git.service.util.*
-import net.logstash.logback.encoder.org.apache.commons.lang.StringEscapeUtils
+import org.apache.commons.lang3.StringEscapeUtils
import org.apache.commons.lang3.StringUtils
import org.apache.commons.lang3.StringUtils.isEmpty
import org.slf4j.LoggerFactory
diff --git a/src/main/kotlin/fr/yodamad/svn2git/service/util/GitBranchManager.kt b/src/main/kotlin/fr/yodamad/svn2git/service/util/GitBranchManager.kt
index 2472a571..53f1bfae 100644
--- a/src/main/kotlin/fr/yodamad/svn2git/service/util/GitBranchManager.kt
+++ b/src/main/kotlin/fr/yodamad/svn2git/service/util/GitBranchManager.kt
@@ -43,7 +43,7 @@ open class GitBranchManager(val gitManager: GitManager,
}
try {
- execCommand(workUnit.commandManager, workUnit.directory, "git checkout -b \"$branchName\" \"$branch\"")
+ execCommand(workUnit.commandManager, workUnit.directory, "git checkout -f -b \"$branchName\" \"$branch\"")
} catch (iEx: IOException) {
LOG.error(FAILED_TO_PUSH_BRANCH, iEx)
historyMgr.endStep(history, StatusEnum.FAILED, iEx.message)
diff --git a/src/main/kotlin/fr/yodamad/svn2git/service/util/GitTagManager.kt b/src/main/kotlin/fr/yodamad/svn2git/service/util/GitTagManager.kt
index f279e503..45303e3b 100644
--- a/src/main/kotlin/fr/yodamad/svn2git/service/util/GitTagManager.kt
+++ b/src/main/kotlin/fr/yodamad/svn2git/service/util/GitTagManager.kt
@@ -53,12 +53,12 @@ open class GitTagManager(val gitManager: GitManager,
val noHistory = workUnit.migration.svnHistory != "all"
// checkout a new branch using local tagName and remote tag name
- execCommand(workUnit.commandManager, workUnit.directory, "git checkout -b tmp_tag \"$tag\"")
+ execCommand(workUnit.commandManager, workUnit.directory, "git checkout -f -b tmp_tag \"$tag\"")
// If this tag does not contain any files we will ignore it and add warning to logs.
if (!isFileInFolder(workUnit.directory)) {
// Switch over to master
- execCommand(workUnit.commandManager, workUnit.directory, "git checkout master")
+ execCommand(workUnit.commandManager, workUnit.directory, "git checkout -f master")
// Now we can delete the branch tmp_tag
execCommand(workUnit.commandManager, workUnit.directory, "git branch -D tmp_tag")
@@ -71,7 +71,7 @@ open class GitTagManager(val gitManager: GitManager,
}
// Checkout master.
- execCommand(workUnit.commandManager, workUnit.directory, "git checkout master")
+ execCommand(workUnit.commandManager, workUnit.directory, "git checkout -f master")
// create tag from tmp_tag branch.
execCommand(workUnit.commandManager, workUnit.directory, "git tag \"$tagName\" tmp_tag")
diff --git a/src/main/kotlin/fr/yodamad/svn2git/web/rest/MappingResource.kt b/src/main/kotlin/fr/yodamad/svn2git/web/rest/MappingResource.kt
index f164f544..d15e0d65 100644
--- a/src/main/kotlin/fr/yodamad/svn2git/web/rest/MappingResource.kt
+++ b/src/main/kotlin/fr/yodamad/svn2git/web/rest/MappingResource.kt
@@ -5,7 +5,7 @@ import fr.yodamad.svn2git.domain.Mapping
import fr.yodamad.svn2git.service.MappingService
import fr.yodamad.svn2git.web.rest.errors.BadRequestAlertException
import fr.yodamad.svn2git.web.rest.util.HeaderUtil
-import io.github.jhipster.web.util.ResponseUtil
+import tech.jhipster.web.util.ResponseUtil
import org.slf4j.LoggerFactory
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
diff --git a/src/main/kotlin/fr/yodamad/svn2git/web/rest/MigrationHistoryResource.kt b/src/main/kotlin/fr/yodamad/svn2git/web/rest/MigrationHistoryResource.kt
index d822a150..82adc057 100644
--- a/src/main/kotlin/fr/yodamad/svn2git/web/rest/MigrationHistoryResource.kt
+++ b/src/main/kotlin/fr/yodamad/svn2git/web/rest/MigrationHistoryResource.kt
@@ -5,7 +5,7 @@ import fr.yodamad.svn2git.domain.MigrationHistory
import fr.yodamad.svn2git.service.MigrationHistoryService
import fr.yodamad.svn2git.web.rest.errors.BadRequestAlertException
import fr.yodamad.svn2git.web.rest.util.HeaderUtil
-import io.github.jhipster.web.util.ResponseUtil
+import tech.jhipster.web.util.ResponseUtil
import org.slf4j.LoggerFactory
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
diff --git a/src/main/kotlin/fr/yodamad/svn2git/web/rest/MigrationRemovedFileResource.kt b/src/main/kotlin/fr/yodamad/svn2git/web/rest/MigrationRemovedFileResource.kt
index 29deabce..8e959b30 100644
--- a/src/main/kotlin/fr/yodamad/svn2git/web/rest/MigrationRemovedFileResource.kt
+++ b/src/main/kotlin/fr/yodamad/svn2git/web/rest/MigrationRemovedFileResource.kt
@@ -5,7 +5,7 @@ import fr.yodamad.svn2git.domain.MigrationRemovedFile
import fr.yodamad.svn2git.service.MigrationRemovedFileService
import fr.yodamad.svn2git.web.rest.errors.BadRequestAlertException
import fr.yodamad.svn2git.web.rest.util.HeaderUtil
-import io.github.jhipster.web.util.ResponseUtil
+import tech.jhipster.web.util.ResponseUtil
import org.slf4j.LoggerFactory
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.*
diff --git a/src/main/kotlin/fr/yodamad/svn2git/web/rest/MigrationResource.kt b/src/main/kotlin/fr/yodamad/svn2git/web/rest/MigrationResource.kt
index 7038eac5..dabbf327 100644
--- a/src/main/kotlin/fr/yodamad/svn2git/web/rest/MigrationResource.kt
+++ b/src/main/kotlin/fr/yodamad/svn2git/web/rest/MigrationResource.kt
@@ -15,7 +15,7 @@ import fr.yodamad.svn2git.web.rest.errors.BadRequestAlertException
import fr.yodamad.svn2git.web.rest.util.HeaderUtil
import fr.yodamad.svn2git.web.rest.util.PaginationUtil
import fr.yodamad.svn2git.web.rest.util.View.Public
-import io.github.jhipster.web.util.ResponseUtil
+import tech.jhipster.web.util.ResponseUtil
import org.apache.commons.lang3.StringUtils
import org.gitlab4j.api.GitLabApiException
import org.slf4j.LoggerFactory
diff --git a/src/main/resources/config/application-dev.yml b/src/main/resources/config/application-dev.yml
index 5bc2c516..f9c5eef7 100644
--- a/src/main/resources/config/application-dev.yml
+++ b/src/main/resources/config/application-dev.yml
@@ -16,15 +16,10 @@
logging:
level:
ROOT: WARN
- io.github.jhipster: WARN
+ tech.jhipster: WARN
fr.yodamad.svn2git: INFO
spring:
- profiles:
- active: dev
- include:
- # Uncomment to activate TLS for the dev profile
- #- tls
devtools:
restart:
enabled: true
@@ -43,7 +38,7 @@ spring:
console:
enabled: false
jpa:
- database-platform: io.github.jhipster.domain.util.FixedH2Dialect
+ database-platform: tech.jhipster.domain.util.FixedH2Dialect
database: H2
show-sql: false
properties:
@@ -74,8 +69,6 @@ server:
# ===================================================================
jhipster:
- http:
- version: V_1_1 # To use HTTP/2 you will need to activate TLS (see application-tls.yml)
# CORS is only enabled by default with the "dev" profile, so BrowserSync can access the API
cors:
allowed-origins: "*"
@@ -95,10 +88,6 @@ jhipster:
mail: # specific JHipster mail property, for standard properties see MailProperties
from: svn2git@localhost
base-url: http://127.0.0.1:8080
- metrics: # DropWizard Metrics configuration, used by MetricsConfiguration
- logs: # Reports Dropwizard metrics in the logs
- enabled: false
- report-frequency: 60 # in seconds
logging:
logstash: # Forward logs to logstash over a socket, used by LoggingConfiguration
enabled: false
diff --git a/src/main/resources/config/application.yml b/src/main/resources/config/application.yml
index 31a2d687..4c4b2186 100644
--- a/src/main/resources/config/application.yml
+++ b/src/main/resources/config/application.yml
@@ -90,7 +90,7 @@ jhipster:
from: svn2git@localhost
logging:
- file: target/svn2git.log
+ file: svn2git.log
# ===================================================================
# Application specific properties
diff --git a/src/test/java/fr/yodamad/svn2git/config/WebConfigurerTest.java b/src/test/java/fr/yodamad/svn2git/config/WebConfigurerTest.java
index 01bc93de..65a8173f 100644
--- a/src/test/java/fr/yodamad/svn2git/config/WebConfigurerTest.java
+++ b/src/test/java/fr/yodamad/svn2git/config/WebConfigurerTest.java
@@ -1,32 +1,25 @@
package fr.yodamad.svn2git.config;
-import com.codahale.metrics.MetricRegistry;
-import com.codahale.metrics.servlet.InstrumentedFilter;
-import com.codahale.metrics.servlets.MetricsServlet;
-import io.github.jhipster.config.JHipsterConstants;
-import io.github.jhipster.config.JHipsterProperties;
-import io.github.jhipster.web.filter.CachingHttpHeadersFilter;
-import io.undertow.Undertow;
-import io.undertow.Undertow.Builder;
-import io.undertow.UndertowOptions;
-import org.apache.commons.io.FilenameUtils;
-
import org.h2.server.web.WebServlet;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.mock.env.MockEnvironment;
import org.springframework.mock.web.MockServletContext;
-import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-import org.xnio.OptionMap;
+import tech.jhipster.config.JHipsterConstants;
+import tech.jhipster.config.JHipsterProperties;
import javax.servlet.*;
-import java.util.*;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*;
@@ -36,29 +29,23 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/**
- * Unit tests for the WebConfigurer class.
- *
- * @see WebConfigurer
+ * Unit tests for the {@link WebConfigurer} class.
*/
-public class WebConfigurerTest {
-
- private WebConfigurer webConfigurer;
+class WebConfigurerTest {
- private MockServletContext servletContext;
+ private static WebConfigurer webConfigurer;
- private MockEnvironment env;
+ private static MockServletContext servletContext;
- private JHipsterProperties props;
+ private static MockEnvironment env;
- private MetricRegistry metricRegistry;
+ private static JHipsterProperties props;
- @Before
+ @BeforeEach
public void setup() {
servletContext = spy(new MockServletContext());
- doReturn(mock(FilterRegistration.Dynamic.class))
- .when(servletContext).addFilter(anyString(), any(Filter.class));
- doReturn(mock(ServletRegistration.Dynamic.class))
- .when(servletContext).addServlet(anyString(), any(Servlet.class));
+ doReturn(mock(FilterRegistration.Dynamic.class)).when(servletContext).addFilter(anyString(), any(Filter.class));
+ doReturn(mock(ServletRegistration.Dynamic.class)).when(servletContext).addServlet(anyString(), any(Servlet.class));
env = new MockEnvironment();
props = new JHipsterProperties();
@@ -67,31 +54,23 @@ public void setup() {
}
@Test
- public void testStartUpProdServletContext() throws ServletException {
+ void shouldStartUpProdServletContext() throws ServletException {
env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
- webConfigurer.onStartup(servletContext);
- assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
- assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
- verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
- verify(servletContext).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
+ assertThatCode(() -> webConfigurer.onStartup(servletContext)).doesNotThrowAnyException();
verify(servletContext, never()).addServlet(eq("H2Console"), any(WebServlet.class));
}
@Test
- public void testStartUpDevServletContext() throws ServletException {
+ void shouldStartUpDevServletContext() throws ServletException {
env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
- webConfigurer.onStartup(servletContext);
- assertThat(servletContext.getAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE)).isEqualTo(metricRegistry);
- assertThat(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).isEqualTo(metricRegistry);
- verify(servletContext).addFilter(eq("webappMetricsFilter"), any(InstrumentedFilter.class));
- verify(servletContext, never()).addFilter(eq("cachingHttpHeadersFilter"), any(CachingHttpHeadersFilter.class));
+ assertThatCode(() -> webConfigurer.onStartup(servletContext)).doesNotThrowAnyException();
verify(servletContext).addServlet(eq("H2Console"), any(WebServlet.class));
}
@Test
- public void testCustomizeServletContainer() {
+ void shouldCustomizeServletContainer() {
env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
UndertowServletWebServerFactory container = new UndertowServletWebServerFactory();
webConfigurer.customize(container);
@@ -99,42 +78,26 @@ public void testCustomizeServletContainer() {
assertThat(container.getMimeMappings().get("html")).isEqualTo("text/html;charset=utf-8");
assertThat(container.getMimeMappings().get("json")).isEqualTo("text/html;charset=utf-8");
if (container.getDocumentRoot() != null) {
- assertThat(container.getDocumentRoot().getPath()).isEqualTo(FilenameUtils.separatorsToSystem("target/www"));
+ assertThat(container.getDocumentRoot()).isEqualTo(new File("target/classes/static/"));
}
-
- Builder builder = Undertow.builder();
- container.getBuilderCustomizers().forEach(c -> c.customize(builder));
- OptionMap.Builder serverOptions = (OptionMap.Builder) ReflectionTestUtils.getField(builder, "serverOptions");
- assertThat(serverOptions.getMap().get(UndertowOptions.ENABLE_HTTP2)).isNull();
}
@Test
- public void testUndertowHttp2Enabled() {
- props.getHttp().setVersion(JHipsterProperties.Http.Version.V_2_0);
- UndertowServletWebServerFactory container = new UndertowServletWebServerFactory();
- webConfigurer.customize(container);
- Builder builder = Undertow.builder();
- container.getBuilderCustomizers().forEach(c -> c.customize(builder));
- OptionMap.Builder serverOptions = (OptionMap.Builder) ReflectionTestUtils.getField(builder, "serverOptions");
- assertThat(serverOptions.getMap().get(UndertowOptions.ENABLE_HTTP2)).isTrue();
- }
-
- @Test
- public void testCorsFilterOnApiPath() throws Exception {
- props.getCors().setAllowedOrigins(Collections.singletonList("*"));
+ void shouldCorsFilterOnApiPath() throws Exception {
+ props.getCors().setAllowedOrigins(Collections.singletonList("other.domain.com"));
props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE"));
props.getCors().setAllowedHeaders(Collections.singletonList("*"));
props.getCors().setMaxAge(1800L);
props.getCors().setAllowCredentials(true);
- MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController())
- .addFilters(webConfigurer.corsFilter())
- .build();
+ MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController()).addFilters(webConfigurer.corsFilter()).build();
- mockMvc.perform(
- options("/api/test-cors")
- .header(HttpHeaders.ORIGIN, "other.domain.com")
- .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "POST"))
+ mockMvc
+ .perform(
+ options("/api/test-cors")
+ .header(HttpHeaders.ORIGIN, "other.domain.com")
+ .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "POST")
+ )
.andExpect(status().isOk())
.andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "other.domain.com"))
.andExpect(header().string(HttpHeaders.VARY, "Origin"))
@@ -142,58 +105,48 @@ public void testCorsFilterOnApiPath() throws Exception {
.andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"))
.andExpect(header().string(HttpHeaders.ACCESS_CONTROL_MAX_AGE, "1800"));
- mockMvc.perform(
- get("/api/test-cors")
- .header(HttpHeaders.ORIGIN, "other.domain.com"))
+ mockMvc
+ .perform(get("/api/test-cors").header(HttpHeaders.ORIGIN, "other.domain.com"))
.andExpect(status().isOk())
.andExpect(header().string(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "other.domain.com"));
}
@Test
- public void testCorsFilterOnOtherPath() throws Exception {
+ void shouldCorsFilterOnOtherPath() throws Exception {
props.getCors().setAllowedOrigins(Collections.singletonList("*"));
props.getCors().setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE"));
props.getCors().setAllowedHeaders(Collections.singletonList("*"));
props.getCors().setMaxAge(1800L);
props.getCors().setAllowCredentials(true);
- MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController())
- .addFilters(webConfigurer.corsFilter())
- .build();
+ MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController()).addFilters(webConfigurer.corsFilter()).build();
- mockMvc.perform(
- get("/test/test-cors")
- .header(HttpHeaders.ORIGIN, "other.domain.com"))
+ mockMvc
+ .perform(get("/test/test-cors").header(HttpHeaders.ORIGIN, "other.domain.com"))
.andExpect(status().isOk())
.andExpect(header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
}
@Test
- public void testCorsFilterDeactivated() throws Exception {
+ void shouldCorsFilterDeactivatedForNullAllowedOrigins() throws Exception {
props.getCors().setAllowedOrigins(null);
- MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController())
- .addFilters(webConfigurer.corsFilter())
- .build();
+ MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController()).addFilters(webConfigurer.corsFilter()).build();
- mockMvc.perform(
- get("/api/test-cors")
- .header(HttpHeaders.ORIGIN, "other.domain.com"))
+ mockMvc
+ .perform(get("/api/test-cors").header(HttpHeaders.ORIGIN, "other.domain.com"))
.andExpect(status().isOk())
.andExpect(header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
}
@Test
- public void testCorsFilterDeactivated2() throws Exception {
+ void shouldCorsFilterDeactivatedForEmptyAllowedOrigins() throws Exception {
props.getCors().setAllowedOrigins(new ArrayList<>());
- MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController())
- .addFilters(webConfigurer.corsFilter())
- .build();
+ MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new WebConfigurerTestController()).addFilters(webConfigurer.corsFilter()).build();
- mockMvc.perform(
- get("/api/test-cors")
- .header(HttpHeaders.ORIGIN, "other.domain.com"))
+ mockMvc
+ .perform(get("/api/test-cors").header(HttpHeaders.ORIGIN, "other.domain.com"))
.andExpect(status().isOk())
.andExpect(header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
}
diff --git a/src/test/java/fr/yodamad/svn2git/e2e/ComplexRepoTests.java b/src/test/java/fr/yodamad/svn2git/e2e/ComplexRepoTests.java
index c7ad1915..4ebf2475 100644
--- a/src/test/java/fr/yodamad/svn2git/e2e/ComplexRepoTests.java
+++ b/src/test/java/fr/yodamad/svn2git/e2e/ComplexRepoTests.java
@@ -12,13 +12,13 @@
import org.gitlab4j.api.models.Branch;
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.Tag;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import javax.annotation.PostConstruct;
import java.util.List;
@@ -32,7 +32,7 @@
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class ComplexRepoTests {
@@ -50,7 +50,7 @@ public void initApi() {
Checks.initApi(applicationProperties);
}
- @Before
+ @BeforeEach
public void cleanGitlab() throws GitLabApiException {
String projectName = complex().name.split("/")[1];
String subGroup = complex().name.split("/")[0];
@@ -59,7 +59,7 @@ public void cleanGitlab() throws GitLabApiException {
if (project.isPresent()) api.getProjectApi().deleteProject(project.get().getId());
}
- @After
+ @AfterEach
public void forceCleanGitlab() throws GitLabApiException, InterruptedException {
Optional project = api.getProjectApi().getOptionalProject(complex().namespace, complex().name);
if (project.isPresent()) api.getProjectApi().deleteProject(project.get().getId());
diff --git a/src/test/java/fr/yodamad/svn2git/e2e/FlatRepoTests.java b/src/test/java/fr/yodamad/svn2git/e2e/FlatRepoTests.java
index 0da9dc2d..22219d65 100644
--- a/src/test/java/fr/yodamad/svn2git/e2e/FlatRepoTests.java
+++ b/src/test/java/fr/yodamad/svn2git/e2e/FlatRepoTests.java
@@ -11,13 +11,13 @@
import org.gitlab4j.api.GitLabApiException;
import org.gitlab4j.api.models.Branch;
import org.gitlab4j.api.models.Project;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import javax.annotation.PostConstruct;
import java.util.List;
@@ -33,7 +33,7 @@
import static fr.yodamad.svn2git.utils.MigrationUtils.initFlatMigration;
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class FlatRepoTests {
@@ -51,13 +51,13 @@ public void initApi() {
Checks.initApi(applicationProperties);
}
- @Before
+ @BeforeEach
public void cleanGitlab() throws GitLabApiException {
Optional project = api.getProjectApi().getOptionalProject(flat().namespace, flat().name);
if (project.isPresent()) api.getProjectApi().deleteProject(project.get().getId());
}
- @After
+ @AfterEach
public void forceCleanGitlab() throws GitLabApiException, InterruptedException {
Optional project = api.getProjectApi().getOptionalProject(flat().namespace, flat().name);
if (project.isPresent()) api.getProjectApi().deleteProject(project.get().getId());
diff --git a/src/test/java/fr/yodamad/svn2git/e2e/SimpleRepoTests.java b/src/test/java/fr/yodamad/svn2git/e2e/SimpleRepoTests.java
index b36910e6..f585c8bc 100644
--- a/src/test/java/fr/yodamad/svn2git/e2e/SimpleRepoTests.java
+++ b/src/test/java/fr/yodamad/svn2git/e2e/SimpleRepoTests.java
@@ -15,14 +15,14 @@
import org.gitlab4j.api.models.Commit;
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.Tag;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
@@ -44,7 +44,7 @@
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.when;
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class SimpleRepoTests {
@@ -64,7 +64,7 @@ public void initApi() {
Checks.initApi(applicationProperties);
}
- @Before
+ @BeforeEach
public void checkGitlab() throws GitLabApiException, InterruptedException {
Optional project = api.getProjectApi().getOptionalProject(simple().namespace, simple().name);
if (project.isPresent()) {
@@ -75,7 +75,7 @@ public void checkGitlab() throws GitLabApiException, InterruptedException {
}
}
- @After
+ @AfterEach
public void cleanGitlab() throws GitLabApiException, InterruptedException {
Optional project = api.getProjectApi().getOptionalProject(simple().namespace, simple().name);
if (project.isPresent()) api.getProjectApi().deleteProject(project.get().getId());
diff --git a/src/test/java/fr/yodamad/svn2git/e2e/WeirdRepoTests.java b/src/test/java/fr/yodamad/svn2git/e2e/WeirdRepoTests.java
index 9aa6588f..86c9848d 100644
--- a/src/test/java/fr/yodamad/svn2git/e2e/WeirdRepoTests.java
+++ b/src/test/java/fr/yodamad/svn2git/e2e/WeirdRepoTests.java
@@ -12,13 +12,13 @@
import org.gitlab4j.api.models.Branch;
import org.gitlab4j.api.models.Project;
import org.gitlab4j.api.models.Tag;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import javax.annotation.PostConstruct;
import java.util.List;
@@ -33,7 +33,7 @@
import static java.lang.Thread.sleep;
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class WeirdRepoTests {
@@ -51,13 +51,13 @@ public void initApi() {
Checks.initApi(applicationProperties);
}
- @Before
+ @BeforeEach
public void cleanGitlab() throws GitLabApiException {
Optional project = api.getProjectApi().getOptionalProject(weird().namespace, weird().name);
if (project.isPresent()) api.getProjectApi().deleteProject(project.get().getId());
}
- @After
+ @AfterEach
public void forceCleanGitlab() throws GitLabApiException, InterruptedException {
Optional project = api.getProjectApi().getOptionalProject(weird().namespace, weird().name);
if (project.isPresent()) api.getProjectApi().deleteProject(project.get().getId());
diff --git a/src/test/java/fr/yodamad/svn2git/repository/CustomAuditEventRepositoryIntTest.java b/src/test/java/fr/yodamad/svn2git/repository/CustomAuditEventRepositoryIntTest.java
index 33e8fa90..f1e47041 100644
--- a/src/test/java/fr/yodamad/svn2git/repository/CustomAuditEventRepositoryIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/repository/CustomAuditEventRepositoryIntTest.java
@@ -4,16 +4,16 @@
import fr.yodamad.svn2git.config.Constants;
import fr.yodamad.svn2git.config.audit.AuditEventConverter;
import fr.yodamad.svn2git.domain.PersistentAuditEvent;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.audit.AuditEvent;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.security.web.authentication.WebAuthenticationDetails;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpSession;
@@ -30,7 +30,7 @@
*
* @see CustomAuditEventRepository
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
@Transactional
public class CustomAuditEventRepositoryIntTest {
@@ -49,7 +49,7 @@ public class CustomAuditEventRepositoryIntTest {
private PersistentAuditEvent testOldUserEvent;
- @Before
+ @BeforeEach
public void setup() {
customAuditEventRepository = new CustomAuditEventRepository(persistenceAuditEventRepository, auditEventConverter);
persistenceAuditEventRepository.deleteAll();
diff --git a/src/test/java/fr/yodamad/svn2git/security/DomainUserDetailsServiceIntTest.java b/src/test/java/fr/yodamad/svn2git/security/DomainUserDetailsServiceIntTest.java
index 50793d67..4c8d312c 100644
--- a/src/test/java/fr/yodamad/svn2git/security/DomainUserDetailsServiceIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/security/DomainUserDetailsServiceIntTest.java
@@ -5,28 +5,29 @@
import fr.yodamad.svn2git.repository.UserRepository;
import fr.yodamad.svn2git.service.client.ArtifactoryAdmin;
import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.Transactional;
import java.util.Locale;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Test class for DomainUserDetailsService.
*
* @see DomainUserDetailsService
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
@Transactional
public class DomainUserDetailsServiceIntTest {
@@ -51,7 +52,7 @@ public class DomainUserDetailsServiceIntTest {
private User userTwo;
private User userThree;
- @Before
+ @BeforeEach
public void init() {
userOne = new User();
userOne.setLogin(USER_ONE_LOGIN);
@@ -108,10 +109,12 @@ public void assertThatUserCanBeFoundByEmail() {
assertThat(userDetails.getUsername()).isEqualTo(USER_TWO_LOGIN);
}
- @Test(expected = UsernameNotFoundException.class)
+ @Test
@Transactional
public void assertThatUserCanNotBeFoundByEmailIgnoreCase() {
- domainUserDetailsService.loadUserByUsername(USER_TWO_EMAIL.toUpperCase(Locale.ENGLISH));
+ assertThrows(UsernameNotFoundException.class, () -> {
+ domainUserDetailsService.loadUserByUsername(USER_TWO_EMAIL.toUpperCase(Locale.ENGLISH));
+ });
}
@Test
@@ -122,10 +125,12 @@ public void assertThatEmailIsPrioritizedOverLogin() {
assertThat(userDetails.getUsername()).isEqualTo(USER_ONE_LOGIN);
}
- @Test(expected = UserNotActivatedException.class)
+ @Test
@Transactional
public void assertThatUserNotActivatedExceptionIsThrownForNotActivatedUsers() {
- domainUserDetailsService.loadUserByUsername(USER_THREE_LOGIN);
+ assertThrows(UserNotActivatedException.class, () -> {
+ domainUserDetailsService.loadUserByUsername(USER_THREE_LOGIN);
+ });
}
}
diff --git a/src/test/java/fr/yodamad/svn2git/security/SecurityUtilsUnitTest.java b/src/test/java/fr/yodamad/svn2git/security/SecurityUtilsUnitTest.java
index 7136dbba..82438235 100644
--- a/src/test/java/fr/yodamad/svn2git/security/SecurityUtilsUnitTest.java
+++ b/src/test/java/fr/yodamad/svn2git/security/SecurityUtilsUnitTest.java
@@ -1,6 +1,6 @@
package fr.yodamad.svn2git.security;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
diff --git a/src/test/java/fr/yodamad/svn2git/security/jwt/JWTFilterTest.java b/src/test/java/fr/yodamad/svn2git/security/jwt/JWTFilterTest.java
index b12f7320..d93c4eae 100644
--- a/src/test/java/fr/yodamad/svn2git/security/jwt/JWTFilterTest.java
+++ b/src/test/java/fr/yodamad/svn2git/security/jwt/JWTFilterTest.java
@@ -1,12 +1,10 @@
package fr.yodamad.svn2git.security.jwt;
import fr.yodamad.svn2git.security.AuthoritiesConstants;
-import io.github.jhipster.config.JHipsterProperties;
import io.jsonwebtoken.io.Decoders;
import io.jsonwebtoken.security.Keys;
-
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
import org.springframework.mock.web.MockFilterChain;
import org.springframework.mock.web.MockHttpServletRequest;
@@ -15,6 +13,7 @@
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.test.util.ReflectionTestUtils;
+import tech.jhipster.config.JHipsterProperties;
import java.util.Collections;
@@ -26,7 +25,7 @@ public class JWTFilterTest {
private JWTFilter jwtFilter;
- @Before
+ @BeforeEach
public void setup() {
JHipsterProperties jHipsterProperties = new JHipsterProperties();
tokenProvider = new TokenProvider(jHipsterProperties);
diff --git a/src/test/java/fr/yodamad/svn2git/security/jwt/TokenProviderTest.java b/src/test/java/fr/yodamad/svn2git/security/jwt/TokenProviderTest.java
index 04f71552..59260563 100644
--- a/src/test/java/fr/yodamad/svn2git/security/jwt/TokenProviderTest.java
+++ b/src/test/java/fr/yodamad/svn2git/security/jwt/TokenProviderTest.java
@@ -1,26 +1,25 @@
package fr.yodamad.svn2git.security.jwt;
import fr.yodamad.svn2git.security.AuthoritiesConstants;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.security.Key;
-import java.util.*;
-
-import org.junit.Before;
-import org.junit.Test;
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.SignatureAlgorithm;
+import io.jsonwebtoken.io.Decoders;
+import io.jsonwebtoken.security.Keys;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.test.util.ReflectionTestUtils;
+import tech.jhipster.config.JHipsterProperties;
-import io.github.jhipster.config.JHipsterProperties;
-import io.jsonwebtoken.Jwts;
-import io.jsonwebtoken.SignatureAlgorithm;
-import io.jsonwebtoken.io.Decoders;
-import io.jsonwebtoken.security.Keys;
+import java.security.Key;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.Collection;
+import java.util.Date;
import static org.assertj.core.api.Assertions.assertThat;
@@ -32,7 +31,7 @@ public class TokenProviderTest {
private JHipsterProperties jHipsterProperties;
private TokenProvider tokenProvider;
- @Before
+ @BeforeEach
public void setup() {
jHipsterProperties = Mockito.mock(JHipsterProperties.class);
tokenProvider = new TokenProvider(jHipsterProperties);
diff --git a/src/test/java/fr/yodamad/svn2git/service/GitManagerTest.java b/src/test/java/fr/yodamad/svn2git/service/GitManagerTest.java
index 85240bbb..5e4e4467 100644
--- a/src/test/java/fr/yodamad/svn2git/service/GitManagerTest.java
+++ b/src/test/java/fr/yodamad/svn2git/service/GitManagerTest.java
@@ -1,6 +1,6 @@
package fr.yodamad.svn2git.service;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/test/java/fr/yodamad/svn2git/service/MailServiceIntTest.java b/src/test/java/fr/yodamad/svn2git/service/MailServiceIntTest.java
index c3234a6e..3541efdb 100644
--- a/src/test/java/fr/yodamad/svn2git/service/MailServiceIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/service/MailServiceIntTest.java
@@ -1,11 +1,11 @@
package fr.yodamad.svn2git.service;
+
import fr.yodamad.svn2git.Svn2GitApp;
import fr.yodamad.svn2git.config.Constants;
import fr.yodamad.svn2git.domain.User;
-import io.github.jhipster.config.JHipsterProperties;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.MockitoAnnotations;
@@ -15,8 +15,9 @@
import org.springframework.context.MessageSource;
import org.springframework.mail.MailSendException;
import org.springframework.mail.javamail.JavaMailSenderImpl;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.thymeleaf.spring5.SpringTemplateEngine;
+import tech.jhipster.config.JHipsterProperties;
import javax.mail.Multipart;
import javax.mail.internet.MimeBodyPart;
@@ -28,7 +29,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class MailServiceIntTest {
@@ -49,7 +50,7 @@ public class MailServiceIntTest {
private MailService mailService;
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
doNothing().when(javaMailSender).send(any(MimeMessage.class));
@@ -116,23 +117,6 @@ public void testSendMultipartHtmlEmail() throws Exception {
assertThat(part.getDataHandler().getContentType()).isEqualTo("text/html;charset=UTF-8");
}
- // TODO : Broken test
-// @Test
-// public void testSendEmailFromTemplate() throws Exception {
-// User user = new User();
-// user.setLogin("john");
-// user.setEmail("john.doe@example.com");
-// user.setLangKey("en");
-// mailService.sendEmailFromTemplate(user, "mail/testEmail", "email.test.title");
-// verify(javaMailSender).send(messageCaptor.capture());
-// MimeMessage message = messageCaptor.getValue();
-// assertThat(message.getSubject()).isEqualTo("test title");
-// assertThat(message.getAllRecipients()[0].toString()).isEqualTo(user.getEmail());
-// assertThat(message.getFrom()[0].toString()).isEqualTo("test@localhost");
-// assertThat(message.getContent().toString()).isEqualToNormalizingNewlines("test title, http://127.0.0.1:8080, john\n");
-// assertThat(message.getDataHandler().getContentType()).isEqualTo("text/html;charset=UTF-8");
-// }
-
@Test
public void testSendActivationEmail() throws Exception {
User user = new User();
diff --git a/src/test/java/fr/yodamad/svn2git/service/UserServiceIntTest.java b/src/test/java/fr/yodamad/svn2git/service/UserServiceIntTest.java
index 7531f38f..6b193c49 100644
--- a/src/test/java/fr/yodamad/svn2git/service/UserServiceIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/service/UserServiceIntTest.java
@@ -7,9 +7,9 @@
import fr.yodamad.svn2git.service.dto.UserDTO;
import fr.yodamad.svn2git.service.util.RandomUtil;
import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -17,7 +17,7 @@
import org.springframework.data.auditing.DateTimeProvider;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.Transactional;
import java.time.Instant;
@@ -34,7 +34,7 @@
*
* @see UserService
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
@Transactional
public class UserServiceIntTest {
@@ -53,7 +53,7 @@ public class UserServiceIntTest {
private User user;
- @Before
+ @BeforeEach
public void init() {
user = new User();
user.setLogin("johndoe");
diff --git a/src/test/java/fr/yodamad/svn2git/utils/Checks.java b/src/test/java/fr/yodamad/svn2git/utils/Checks.java
index 77c1834c..b019bccf 100644
--- a/src/test/java/fr/yodamad/svn2git/utils/Checks.java
+++ b/src/test/java/fr/yodamad/svn2git/utils/Checks.java
@@ -12,7 +12,7 @@
import static fr.yodamad.svn2git.data.Repository.Dirs.FOLDER;
import static fr.yodamad.svn2git.data.Repository.Files.*;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
public class Checks {
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/AccountResourceIntTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/AccountResourceIntTest.java
index 8229fc29..9eee7892 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/AccountResourceIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/AccountResourceIntTest.java
@@ -14,9 +14,9 @@
import fr.yodamad.svn2git.web.rest.errors.ExceptionTranslator;
import fr.yodamad.svn2git.web.rest.vm.KeyAndPasswordVM;
import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
@@ -25,7 +25,7 @@
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.test.context.support.WithMockUser;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;
@@ -49,7 +49,7 @@
*
* @see AccountResource
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class AccountResourceIntTest {
@@ -81,7 +81,7 @@ public class AccountResourceIntTest {
private MockMvc restUserMockMvc;
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
doNothing().when(mockMailService).sendActivationEmail(any());
@@ -139,7 +139,7 @@ public void testGetExistingAccount() throws Exception {
restUserMockMvc.perform(get("/api/account")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.login").value("test"))
.andExpect(jsonPath("$.firstName").value("john"))
.andExpect(jsonPath("$.lastName").value("doe"))
@@ -158,297 +158,6 @@ public void testGetUnknownAccount() throws Exception {
.andExpect(status().isInternalServerError());
}
- // TODO : Broken Test
-// @Test
-// @Transactional
-// public void testRegisterValid() throws Exception {
-// ManagedUserVM validUser = new ManagedUserVM();
-// validUser.setLogin("test-register-valid");
-// validUser.setPassword("password");
-// validUser.setFirstName("Alice");
-// validUser.setLastName("Test");
-// validUser.setEmail("test-register-valid@example.com");
-// validUser.setImageUrl("http://placehold.it/50x50");
-// validUser.setLangKey(Constants.DEFAULT_LANGUAGE);
-// validUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
-// assertThat(userRepository.findOneByLogin("test-register-valid").isPresent()).isFalse();
-//
-// restMvc.perform(
-// post("/api/register")
-// .contentType(TestUtil.APPLICATION_JSON_UTF8)
-// .content(TestUtil.convertObjectToJsonBytes(validUser)))
-// .andExpect(status().isCreated());
-//
-// assertThat(userRepository.findOneByLogin("test-register-valid").isPresent()).isTrue();
-// }
-
- // TODO : Broken Test
-// @Test
-// @Transactional
-// public void testRegisterInvalidLogin() throws Exception {
-// ManagedUserVM invalidUser = new ManagedUserVM();
-// invalidUser.setLogin("funky-log!n");// <-- invalid
-// invalidUser.setPassword("password");
-// invalidUser.setFirstName("Funky");
-// invalidUser.setLastName("One");
-// invalidUser.setEmail("funky@example.com");
-// invalidUser.setActivated(true);
-// invalidUser.setImageUrl("http://placehold.it/50x50");
-// invalidUser.setLangKey(Constants.DEFAULT_LANGUAGE);
-// invalidUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
-//
-// restUserMockMvc.perform(
-// post("/api/register")
-// .contentType(TestUtil.APPLICATION_JSON_UTF8)
-// .content(TestUtil.convertObjectToJsonBytes(invalidUser)))
-// .andExpect(status().isBadRequest());
-//
-// Optional user = userRepository.findOneByEmailIgnoreCase("funky@example.com");
-// assertThat(user.isPresent()).isFalse();
-// }
-
- // TODO : Broken Test
-// @Test
-// @Transactional
-// public void testRegisterInvalidEmail() throws Exception {
-// ManagedUserVM invalidUser = new ManagedUserVM();
-// invalidUser.setLogin("bob");
-// invalidUser.setPassword("password");
-// invalidUser.setFirstName("Bob");
-// invalidUser.setLastName("Green");
-// invalidUser.setEmail("invalid");// <-- invalid
-// invalidUser.setActivated(true);
-// invalidUser.setImageUrl("http://placehold.it/50x50");
-// invalidUser.setLangKey(Constants.DEFAULT_LANGUAGE);
-// invalidUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
-//
-// restUserMockMvc.perform(
-// post("/api/register")
-// .contentType(TestUtil.APPLICATION_JSON_UTF8)
-// .content(TestUtil.convertObjectToJsonBytes(invalidUser)))
-// .andExpect(status().isBadRequest());
-//
-// Optional user = userRepository.findOneByLogin("bob");
-// assertThat(user.isPresent()).isFalse();
-// }
-
- // TODO: Broken Test
-// @Test
-// @Transactional
-// public void testRegisterInvalidPassword() throws Exception {
-// ManagedUserVM invalidUser = new ManagedUserVM();
-// invalidUser.setLogin("bob");
-// invalidUser.setPassword("123");// password with only 3 digits
-// invalidUser.setFirstName("Bob");
-// invalidUser.setLastName("Green");
-// invalidUser.setEmail("bob@example.com");
-// invalidUser.setActivated(true);
-// invalidUser.setImageUrl("http://placehold.it/50x50");
-// invalidUser.setLangKey(Constants.DEFAULT_LANGUAGE);
-// invalidUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
-//
-// restUserMockMvc.perform(
-// post("/api/register")
-// .contentType(TestUtil.APPLICATION_JSON_UTF8)
-// .content(TestUtil.convertObjectToJsonBytes(invalidUser)))
-// .andExpect(status().isBadRequest());
-//
-// Optional user = userRepository.findOneByLogin("bob");
-// assertThat(user.isPresent()).isFalse();
-// }
-
- // TODO : Broken Test
-// @Test
-// @Transactional
-// public void testRegisterNullPassword() throws Exception {
-// ManagedUserVM invalidUser = new ManagedUserVM();
-// invalidUser.setLogin("bob");
-// invalidUser.setPassword(null);// invalid null password
-// invalidUser.setFirstName("Bob");
-// invalidUser.setLastName("Green");
-// invalidUser.setEmail("bob@example.com");
-// invalidUser.setActivated(true);
-// invalidUser.setImageUrl("http://placehold.it/50x50");
-// invalidUser.setLangKey(Constants.DEFAULT_LANGUAGE);
-// invalidUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
-//
-// restUserMockMvc.perform(
-// post("/api/register")
-// .contentType(TestUtil.APPLICATION_JSON_UTF8)
-// .content(TestUtil.convertObjectToJsonBytes(invalidUser)))
-// .andExpect(status().isBadRequest());
-//
-// Optional user = userRepository.findOneByLogin("bob");
-// assertThat(user.isPresent()).isFalse();
-// }
-
- // Todo : Broken Test
-// @Test
-// @Transactional
-// public void testRegisterDuplicateLogin() throws Exception {
-// // First registration
-// ManagedUserVM firstUser = new ManagedUserVM();
-// firstUser.setLogin("alice");
-// firstUser.setPassword("password");
-// firstUser.setFirstName("Alice");
-// firstUser.setLastName("Something");
-// firstUser.setEmail("alice@example.com");
-// firstUser.setImageUrl("http://placehold.it/50x50");
-// firstUser.setLangKey(Constants.DEFAULT_LANGUAGE);
-// firstUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
-//
-// // Duplicate login, different email
-// ManagedUserVM secondUser = new ManagedUserVM();
-// secondUser.setLogin(firstUser.getLogin());
-// secondUser.setPassword(firstUser.getPassword());
-// secondUser.setFirstName(firstUser.getFirstName());
-// secondUser.setLastName(firstUser.getLastName());
-// secondUser.setEmail("alice2@example.com");
-// secondUser.setImageUrl(firstUser.getImageUrl());
-// secondUser.setLangKey(firstUser.getLangKey());
-// secondUser.setCreatedBy(firstUser.getCreatedBy());
-// secondUser.setCreatedDate(firstUser.getCreatedDate());
-// secondUser.setLastModifiedBy(firstUser.getLastModifiedBy());
-// secondUser.setLastModifiedDate(firstUser.getLastModifiedDate());
-// secondUser.setAuthorities(new HashSet<>(firstUser.getAuthorities()));
-//
-// // First user
-// restMvc.perform(
-// post("/api/register")
-// .contentType(TestUtil.APPLICATION_JSON_UTF8)
-// .content(TestUtil.convertObjectToJsonBytes(firstUser)))
-// .andExpect(status().isCreated());
-//
-// // Second (non activated) user
-// restMvc.perform(
-// post("/api/register")
-// .contentType(TestUtil.APPLICATION_JSON_UTF8)
-// .content(TestUtil.convertObjectToJsonBytes(secondUser)))
-// .andExpect(status().isCreated());
-//
-// Optional testUser = userRepository.findOneByEmailIgnoreCase("alice2@example.com");
-// assertThat(testUser.isPresent()).isTrue();
-// testUser.get().setActivated(true);
-// userRepository.save(testUser.get());
-//
-// // Second (already activated) user
-// restMvc.perform(
-// post("/api/register")
-// .contentType(TestUtil.APPLICATION_JSON_UTF8)
-// .content(TestUtil.convertObjectToJsonBytes(secondUser)))
-// .andExpect(status().is4xxClientError());
-// }
-
- // Todo : Broken Test
-// @Test
-// @Transactional
-// public void testRegisterDuplicateEmail() throws Exception {
-// // First user
-// ManagedUserVM firstUser = new ManagedUserVM();
-// firstUser.setLogin("test-register-duplicate-email");
-// firstUser.setPassword("password");
-// firstUser.setFirstName("Alice");
-// firstUser.setLastName("Test");
-// firstUser.setEmail("test-register-duplicate-email@example.com");
-// firstUser.setImageUrl("http://placehold.it/50x50");
-// firstUser.setLangKey(Constants.DEFAULT_LANGUAGE);
-// firstUser.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
-//
-// // Register first user
-// restMvc.perform(
-// post("/api/register")
-// .contentType(TestUtil.APPLICATION_JSON_UTF8)
-// .content(TestUtil.convertObjectToJsonBytes(firstUser)))
-// .andExpect(status().isCreated());
-//
-// Optional testUser1 = userRepository.findOneByLogin("test-register-duplicate-email");
-// assertThat(testUser1.isPresent()).isTrue();
-//
-// // Duplicate email, different login
-// ManagedUserVM secondUser = new ManagedUserVM();
-// secondUser.setLogin("test-register-duplicate-email-2");
-// secondUser.setPassword(firstUser.getPassword());
-// secondUser.setFirstName(firstUser.getFirstName());
-// secondUser.setLastName(firstUser.getLastName());
-// secondUser.setEmail(firstUser.getEmail());
-// secondUser.setImageUrl(firstUser.getImageUrl());
-// secondUser.setLangKey(firstUser.getLangKey());
-// secondUser.setAuthorities(new HashSet<>(firstUser.getAuthorities()));
-//
-// // Register second (non activated) user
-// restMvc.perform(
-// post("/api/register")
-// .contentType(TestUtil.APPLICATION_JSON_UTF8)
-// .content(TestUtil.convertObjectToJsonBytes(secondUser)))
-// .andExpect(status().isCreated());
-//
-// Optional testUser2 = userRepository.findOneByLogin("test-register-duplicate-email");
-// assertThat(testUser2.isPresent()).isFalse();
-//
-// Optional testUser3 = userRepository.findOneByLogin("test-register-duplicate-email-2");
-// assertThat(testUser3.isPresent()).isTrue();
-//
-// // Duplicate email - with uppercase email address
-// ManagedUserVM userWithUpperCaseEmail = new ManagedUserVM();
-// userWithUpperCaseEmail.setId(firstUser.getId());
-// userWithUpperCaseEmail.setLogin("test-register-duplicate-email-3");
-// userWithUpperCaseEmail.setPassword(firstUser.getPassword());
-// userWithUpperCaseEmail.setFirstName(firstUser.getFirstName());
-// userWithUpperCaseEmail.setLastName(firstUser.getLastName());
-// userWithUpperCaseEmail.setEmail("TEST-register-duplicate-email@example.com");
-// userWithUpperCaseEmail.setImageUrl(firstUser.getImageUrl());
-// userWithUpperCaseEmail.setLangKey(firstUser.getLangKey());
-// userWithUpperCaseEmail.setAuthorities(new HashSet<>(firstUser.getAuthorities()));
-//
-// // Register third (not activated) user
-// restMvc.perform(
-// post("/api/register")
-// .contentType(TestUtil.APPLICATION_JSON_UTF8)
-// .content(TestUtil.convertObjectToJsonBytes(userWithUpperCaseEmail)))
-// .andExpect(status().isCreated());
-//
-// Optional testUser4 = userRepository.findOneByLogin("test-register-duplicate-email-3");
-// assertThat(testUser4.isPresent()).isTrue();
-// assertThat(testUser4.get().getEmail()).isEqualTo("test-register-duplicate-email@example.com");
-//
-// testUser4.get().setActivated(true);
-// userService.updateUser((new UserDTO(testUser4.get())));
-//
-// // Register 4th (already activated) user
-// restMvc.perform(
-// post("/api/register")
-// .contentType(TestUtil.APPLICATION_JSON_UTF8)
-// .content(TestUtil.convertObjectToJsonBytes(secondUser)))
-// .andExpect(status().is4xxClientError());
-// }
-
- // TODO: Broken Test
-// @Test
-// @Transactional
-// public void testRegisterAdminIsIgnored() throws Exception {
-// ManagedUserVM validUser = new ManagedUserVM();
-// validUser.setLogin("badguy");
-// validUser.setPassword("password");
-// validUser.setFirstName("Bad");
-// validUser.setLastName("Guy");
-// validUser.setEmail("badguy@example.com");
-// validUser.setActivated(true);
-// validUser.setImageUrl("http://placehold.it/50x50");
-// validUser.setLangKey(Constants.DEFAULT_LANGUAGE);
-// validUser.setAuthorities(Collections.singleton(AuthoritiesConstants.ADMIN));
-//
-// restMvc.perform(
-// post("/api/register")
-// .contentType(TestUtil.APPLICATION_JSON_UTF8)
-// .content(TestUtil.convertObjectToJsonBytes(validUser)))
-// .andExpect(status().isCreated());
-//
-// Optional userDup = userRepository.findOneByLogin("badguy");
-// assertThat(userDup.isPresent()).isTrue();
-// assertThat(userDup.get().getAuthorities()).hasSize(1)
-// .containsExactly(authorityRepository.findById(AuthoritiesConstants.USER).get());
-// }
-
@Test
@Transactional
public void testActivateAccount() throws Exception {
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/AuditResourceIntTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/AuditResourceIntTest.java
index 7a50e25b..336d6a7f 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/AuditResourceIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/AuditResourceIntTest.java
@@ -6,9 +6,9 @@
import fr.yodamad.svn2git.repository.PersistenceAuditEventRepository;
import fr.yodamad.svn2git.service.AuditEventService;
import fr.yodamad.svn2git.service.client.ArtifactoryAdmin;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -17,7 +17,7 @@
import org.springframework.format.support.FormattingConversionService;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;
@@ -33,7 +33,7 @@
*
* @see AuditResource
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
@Transactional
public class AuditResourceIntTest {
@@ -65,7 +65,7 @@ public class AuditResourceIntTest {
@MockBean
ArtifactoryAdmin artifactoryAdmin;
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
AuditEventService auditEventService =
@@ -75,10 +75,7 @@ public void setup() {
.setCustomArgumentResolvers(pageableArgumentResolver)
.setConversionService(formattingConversionService)
.setMessageConverters(jacksonMessageConverter).build();
- }
- @Before
- public void initTest() {
auditEventRepository.deleteAll();
auditEvent = new PersistentAuditEvent();
auditEvent.setAuditEventType(SAMPLE_TYPE);
@@ -94,7 +91,7 @@ public void getAllAudits() throws Exception {
// Get all the audits
restAuditMockMvc.perform(get("/management/audits"))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].principal").value(hasItem(SAMPLE_PRINCIPAL)));
}
@@ -106,7 +103,7 @@ public void getAudit() throws Exception {
// Get the audit
restAuditMockMvc.perform(get("/management/audits/{id}", auditEvent.getId()))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.principal").value(SAMPLE_PRINCIPAL));
}
@@ -122,7 +119,7 @@ public void getAuditsByDate() throws Exception {
// Get the audit
restAuditMockMvc.perform(get("/management/audits?fromDate="+fromDate+"&toDate="+toDate))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].principal").value(hasItem(SAMPLE_PRINCIPAL)));
}
@@ -138,7 +135,7 @@ public void getNonExistingAuditsByDate() throws Exception {
// Query audits but expect no results
restAuditMockMvc.perform(get("/management/audits?fromDate=" + fromDate + "&toDate=" + toDate))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(header().string("X-Total-Count", "0"));
}
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/LogsResourceIntTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/LogsResourceIntTest.java
index f8d3139c..02c33b12 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/LogsResourceIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/LogsResourceIntTest.java
@@ -1,20 +1,16 @@
package fr.yodamad.svn2git.web.rest;
-import ch.qos.logback.classic.AsyncAppender;
-import ch.qos.logback.classic.LoggerContext;
import fr.yodamad.svn2git.Svn2GitApp;
import fr.yodamad.svn2git.web.rest.vm.LoggerVM;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.slf4j.LoggerFactory;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
@@ -25,13 +21,13 @@
*
* @see LogsResource
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class LogsResourceIntTest {
private MockMvc restLogsMockMvc;
- @Before
+ @BeforeEach
public void setup() {
LogsResource logsResource = new LogsResource();
this.restLogsMockMvc = MockMvcBuilders
@@ -43,7 +39,7 @@ public void setup() {
public void getAllLogs() throws Exception {
restLogsMockMvc.perform(get("/management/logs"))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE));
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE));
}
@Test
@@ -57,10 +53,4 @@ public void changeLogs() throws Exception {
.content(TestUtil.convertObjectToJsonBytes(logger)))
.andExpect(status().isNoContent());
}
-
- @Test
- public void testLogstashAppender() {
- LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
- assertThat(context.getLogger("ROOT").getAppender("ASYNC_LOGSTASH")).isInstanceOf(AsyncAppender.class);
- }
}
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/MappingResourceIntTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/MappingResourceIntTest.java
index 13c8b413..688cea1f 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/MappingResourceIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/MappingResourceIntTest.java
@@ -5,16 +5,16 @@
import fr.yodamad.svn2git.repository.MappingRepository;
import fr.yodamad.svn2git.service.MappingService;
import fr.yodamad.svn2git.web.rest.errors.ExceptionTranslator;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;
@@ -33,7 +33,7 @@
*
* @see MappingResource
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class MappingResourceIntTest {
@@ -71,7 +71,7 @@ public class MappingResourceIntTest {
private Mapping mapping;
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
final MappingResource mappingResource = new MappingResource(mappingService);
@@ -97,7 +97,7 @@ public static Mapping createEntity(EntityManager em) {
return mapping;
}
- @Before
+ @BeforeEach
public void initTest() {
mapping = createEntity(em);
}
@@ -151,7 +151,7 @@ public void getAllMappings() throws Exception {
// Get all the mappingList
restMappingMockMvc.perform(get("/api/mappings?sort=id,desc"))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(mapping.getId().intValue())))
.andExpect(jsonPath("$.[*].svnDirectory").value(hasItem(DEFAULT_SVN_DIRECTORY.toString())))
.andExpect(jsonPath("$.[*].regex").value(hasItem(DEFAULT_REGEX.toString())))
@@ -168,7 +168,7 @@ public void getMapping() throws Exception {
// Get the mapping
restMappingMockMvc.perform(get("/api/mappings/{id}", mapping.getId()))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.id").value(mapping.getId().intValue()))
.andExpect(jsonPath("$.svnDirectory").value(DEFAULT_SVN_DIRECTORY.toString()))
.andExpect(jsonPath("$.regex").value(DEFAULT_REGEX.toString()))
@@ -176,14 +176,6 @@ public void getMapping() throws Exception {
.andExpect(jsonPath("$.svnDirectoryDelete").value(DEFAULT_SVN_DIRECTORY_DELETE.booleanValue()));
}
- @Test
- @Transactional
- public void getNonExistingMapping() throws Exception {
- // Get the mapping
- restMappingMockMvc.perform(get("/api/mappings/{id}", Long.MAX_VALUE))
- .andExpect(status().isNotFound());
- }
-
@Test
@Transactional
public void updateMapping() throws Exception {
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/MigrationHistoryResourceIntTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/MigrationHistoryResourceIntTest.java
index 90e85531..caf16fcc 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/MigrationHistoryResourceIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/MigrationHistoryResourceIntTest.java
@@ -1,22 +1,22 @@
package fr.yodamad.svn2git.web.rest;
import fr.yodamad.svn2git.Svn2GitApp;
-
import fr.yodamad.svn2git.domain.MigrationHistory;
+import fr.yodamad.svn2git.domain.enumeration.StatusEnum;
+import fr.yodamad.svn2git.domain.enumeration.StepEnum;
import fr.yodamad.svn2git.repository.MigrationHistoryRepository;
import fr.yodamad.svn2git.service.MigrationHistoryService;
import fr.yodamad.svn2git.web.rest.errors.ExceptionTranslator;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;
@@ -26,21 +26,17 @@
import java.time.temporal.ChronoUnit;
import java.util.List;
-
import static fr.yodamad.svn2git.web.rest.TestUtil.createFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
-
-import fr.yodamad.svn2git.domain.enumeration.StepEnum;
-import fr.yodamad.svn2git.domain.enumeration.StatusEnum;
/**
* Test class for the MigrationHistoryResource REST controller.
*
* @see MigrationHistoryResource
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class MigrationHistoryResourceIntTest {
@@ -58,7 +54,7 @@ public class MigrationHistoryResourceIntTest {
@Autowired
private MigrationHistoryRepository migrationHistoryRepository;
-
+
@Autowired
private MigrationHistoryService migrationHistoryService;
@@ -78,7 +74,7 @@ public class MigrationHistoryResourceIntTest {
private MigrationHistory migrationHistory;
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
final MigrationHistoryResource migrationHistoryResource = new MigrationHistoryResource(migrationHistoryService);
@@ -87,6 +83,7 @@ public void setup() {
.setControllerAdvice(exceptionTranslator)
.setConversionService(createFormattingConversionService())
.setMessageConverters(jacksonMessageConverter).build();
+ migrationHistory = createEntity(em);
}
/**
@@ -104,11 +101,6 @@ public static MigrationHistory createEntity(EntityManager em) {
return migrationHistory;
}
- @Before
- public void initTest() {
- migrationHistory = createEntity(em);
- }
-
@Test
@Transactional
public void createMigrationHistory() throws Exception {
@@ -158,14 +150,14 @@ public void getAllMigrationHistories() throws Exception {
// Get all the migrationHistoryList
restMigrationHistoryMockMvc.perform(get("/api/migration-histories?sort=id,desc"))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(migrationHistory.getId().intValue())))
.andExpect(jsonPath("$.[*].step").value(hasItem(DEFAULT_STEP.toString())))
.andExpect(jsonPath("$.[*].status").value(hasItem(DEFAULT_STATUS.toString())))
.andExpect(jsonPath("$.[*].date").value(hasItem(DEFAULT_DATE.toString())))
.andExpect(jsonPath("$.[*].data").value(hasItem(DEFAULT_DATA.toString())));
}
-
+
@Test
@Transactional
public void getMigrationHistory() throws Exception {
@@ -175,7 +167,7 @@ public void getMigrationHistory() throws Exception {
// Get the migrationHistory
restMigrationHistoryMockMvc.perform(get("/api/migration-histories/{id}", migrationHistory.getId()))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.id").value(migrationHistory.getId().intValue()))
.andExpect(jsonPath("$.step").value(DEFAULT_STEP.toString()))
.andExpect(jsonPath("$.status").value(DEFAULT_STATUS.toString()))
@@ -183,14 +175,6 @@ public void getMigrationHistory() throws Exception {
.andExpect(jsonPath("$.data").value(DEFAULT_DATA.toString()));
}
- @Test
- @Transactional
- public void getNonExistingMigrationHistory() throws Exception {
- // Get the migrationHistory
- restMigrationHistoryMockMvc.perform(get("/api/migration-histories/{id}", Long.MAX_VALUE))
- .andExpect(status().isNotFound());
- }
-
@Test
@Transactional
public void updateMigrationHistory() throws Exception {
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/MigrationRemovedFileResourceIntTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/MigrationRemovedFileResourceIntTest.java
index 5203cb28..1428c47d 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/MigrationRemovedFileResourceIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/MigrationRemovedFileResourceIntTest.java
@@ -14,16 +14,16 @@
import fr.yodamad.svn2git.service.MigrationRemovedFileService;
import fr.yodamad.svn2git.web.rest.errors.ExceptionTranslator;
import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@@ -43,7 +43,7 @@
*
* @see MigrationRemovedFileResource
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class MigrationRemovedFileResourceIntTest {
@@ -124,7 +124,7 @@ public class MigrationRemovedFileResourceIntTest {
@Autowired
private ApplicationProperties applicationProperties;
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
final MigrationRemovedFileResource migrationRemovedFileResource = new MigrationRemovedFileResource(migrationRemovedFileService);
@@ -140,6 +140,10 @@ public void setup() {
.setControllerAdvice(exceptionTranslator)
.setConversionService(createFormattingConversionService())
.setMessageConverters(jacksonMessageConverter).build();
+
+ migrationRemovedFile = createEntity(em);
+ // create an instance of Migration
+ migration = MigrationResourceIntTest.createEntity(em);
}
/**
@@ -157,13 +161,6 @@ public static MigrationRemovedFile createEntity(EntityManager em) {
return migrationRemovedFile;
}
- @Before
- public void initTest() {
- migrationRemovedFile = createEntity(em);
- // create an instance of Migration
- migration = MigrationResourceIntTest.createEntity(em);
- }
-
@Test
@Transactional
public void createMigrationRemovedFile() throws Exception {
@@ -220,7 +217,7 @@ public void getAllMigrationRemovedFiles() throws Exception {
// Get all the migrationRemovedFileList
restMigrationRemovedFileMockMvc.perform(get("/api/migration-removed-files?sort=id,desc"))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(migrationRemovedFile.getId().intValue())))
.andExpect(jsonPath("$.[*].svnLocation").value(hasItem(DEFAULT_SVN_LOCATION.toString())))
.andExpect(jsonPath("$.[*].path").value(hasItem(DEFAULT_PATH.toString())))
@@ -242,7 +239,7 @@ public void getMigrationRemovedFile() throws Exception {
// Get the migrationRemovedFile
restMigrationRemovedFileMockMvc.perform(get("/api/migration-removed-files/{id}", migrationRemovedFile.getId()))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.id").value(migrationRemovedFile.getId().intValue()))
.andExpect(jsonPath("$.svnLocation").value(DEFAULT_SVN_LOCATION.toString()))
.andExpect(jsonPath("$.path").value(DEFAULT_PATH.toString()))
@@ -289,16 +286,6 @@ public Migration createMigration() throws Exception {
}
-
-
- @Test
- @Transactional
- public void getNonExistingMigrationRemovedFile() throws Exception {
- // Get the migrationRemovedFile
- restMigrationRemovedFileMockMvc.perform(get("/api/migration-removed-files/{id}", Long.MAX_VALUE))
- .andExpect(status().isNotFound());
- }
-
@Test
@Transactional
public void updateMigrationRemovedFile() throws Exception {
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/MigrationResourceIntTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/MigrationResourceIntTest.java
index 0a87a698..1c5149d5 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/MigrationResourceIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/MigrationResourceIntTest.java
@@ -12,16 +12,16 @@
import fr.yodamad.svn2git.web.rest.errors.ExceptionTranslator;
import org.apache.commons.lang3.RandomUtils;
import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@@ -43,7 +43,7 @@
*
* @see MigrationResource
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class MigrationResourceIntTest {
@@ -103,7 +103,7 @@ public class MigrationResourceIntTest {
@Autowired
private ApplicationProperties applicationProperties;
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
final MigrationResource migrationResource = new MigrationResource(migrationRepository, migrationManager, migrationHistoryService, mappingService, gitlabResource, applicationProperties);
@@ -112,6 +112,7 @@ public void setup() {
.setControllerAdvice(exceptionTranslator)
.setConversionService(createFormattingConversionService())
.setMessageConverters(jacksonMessageConverter).build();
+ migration = createEntity(em);
}
/**
@@ -133,11 +134,6 @@ public static Migration createEntity(EntityManager em) {
return migration;
}
- @Before
- public void initTest() {
- migration = createEntity(em);
- }
-
@Test
@Transactional
public void createMigration() throws Exception {
@@ -283,7 +279,7 @@ public void getAllMigrations() throws Exception {
// Get all the migrationList
restMigrationMockMvc.perform(get("/api/migrations?sort=id,desc"))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(migration.getId().intValue())))
.andExpect(jsonPath("$.[*].svnGroup").value(hasItem(DEFAULT_SVN_GROUP.toString())))
.andExpect(jsonPath("$.[*].svnProject").value(hasItem(DEFAULT_SVN_PROJECT.toString())))
@@ -303,7 +299,7 @@ public void getMigration() throws Exception {
// Get the migration
MvcResult restMigrationMockMvcResult = restMigrationMockMvc.perform(get("/api/migrations/{id}", migration.getId()))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.id").value(migration.getId().intValue()))
.andExpect(jsonPath("$.svnGroup").value(DEFAULT_SVN_GROUP.toString()))
.andExpect(jsonPath("$.svnProject").value(DEFAULT_SVN_PROJECT.toString()))
@@ -320,14 +316,6 @@ public void getMigration() throws Exception {
}
- @Test
- @Transactional
- public void getNonExistingMigration() throws Exception {
- // Get the migration
- restMigrationMockMvc.perform(get("/api/migrations/{id}", Long.MAX_VALUE))
- .andExpect(status().isNotFound());
- }
-
@Test
@Transactional
public void updateMigration() throws Exception {
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/MigrationResourceIntTest2.java b/src/test/java/fr/yodamad/svn2git/web/rest/MigrationResourceIntTest2.java
index 8c4b0579..3eee37b0 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/MigrationResourceIntTest2.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/MigrationResourceIntTest2.java
@@ -9,16 +9,16 @@
import fr.yodamad.svn2git.service.MigrationHistoryService;
import fr.yodamad.svn2git.service.MigrationManager;
import fr.yodamad.svn2git.web.rest.errors.ExceptionTranslator;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.core.io.ResourceLoader;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
@@ -38,7 +38,7 @@
*
* @see MigrationResource
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class MigrationResourceIntTest2 {
@@ -79,7 +79,7 @@ public class MigrationResourceIntTest2 {
@Autowired
ResourceLoader resourceLoader;
- @Before
+ @BeforeAll
public void setup() {
MockitoAnnotations.initMocks(this);
final MigrationResource migrationResource = new MigrationResource(migrationRepository, migrationManager, migrationHistoryService, mappingService, gitlabResource, applicationProperties);
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/Migration_historyResourceIntTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/Migration_historyResourceIntTest.java
index b929dfe0..f54a584c 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/Migration_historyResourceIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/Migration_historyResourceIntTest.java
@@ -1,25 +1,23 @@
package fr.yodamad.svn2git.web.rest;
import fr.yodamad.svn2git.Svn2GitApp;
-
import fr.yodamad.svn2git.domain.MigrationHistory;
+import fr.yodamad.svn2git.domain.enumeration.StatusEnum;
+import fr.yodamad.svn2git.domain.enumeration.StepEnum;
import fr.yodamad.svn2git.repository.MigrationHistoryRepository;
import fr.yodamad.svn2git.service.MigrationHistoryService;
import fr.yodamad.svn2git.web.rest.errors.ExceptionTranslator;
-
-import fr.yodamad.svn2git.domain.enumeration.StatusEnum;
-import fr.yodamad.svn2git.domain.enumeration.StepEnum;
import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;
@@ -29,7 +27,6 @@
import java.time.temporal.ChronoUnit;
import java.util.List;
-
import static fr.yodamad.svn2git.web.rest.TestUtil.createFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
@@ -41,7 +38,7 @@
*
* @see MigrationHistoryResource
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class Migration_historyResourceIntTest {
@@ -56,7 +53,7 @@ public class Migration_historyResourceIntTest {
@Autowired
private MigrationHistoryRepository migration_historyRepository;
-
+
@Autowired
private MigrationHistoryService migration_historyService;
@@ -76,7 +73,7 @@ public class Migration_historyResourceIntTest {
private MigrationHistory migration_history;
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
final MigrationHistoryResource migration_historyResource = new MigrationHistoryResource(migration_historyService);
@@ -85,6 +82,7 @@ public void setup() {
.setControllerAdvice(exceptionTranslator)
.setConversionService(createFormattingConversionService())
.setMessageConverters(jacksonMessageConverter).build();
+ migration_history = createEntity(em);
}
/**
@@ -101,11 +99,6 @@ public static MigrationHistory createEntity(EntityManager em) {
return migration_history;
}
- @Before
- public void initTest() {
- migration_history = createEntity(em);
- }
-
@Test
@Transactional
public void createMigration_history() throws Exception {
@@ -154,13 +147,13 @@ public void getAllMigration_histories() throws Exception {
// Get all the migration_historyList
restMigration_historyMockMvc.perform(get("/api/migration-histories?sort=id,desc"))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(migration_history.getId().intValue())))
.andExpect(jsonPath("$.[*].step").value(hasItem(DEFAULT_STEP.toString())))
.andExpect(jsonPath("$.[*].status").value(hasItem(DEFAULT_STATUS.toString())))
.andExpect(jsonPath("$.[*].date").value(hasItem(DEFAULT_DATE.toString())));
}
-
+
@Test
@Transactional
public void getMigration_history() throws Exception {
@@ -170,21 +163,13 @@ public void getMigration_history() throws Exception {
// Get the migration_history
restMigration_historyMockMvc.perform(get("/api/migration-histories/{id}", migration_history.getId()))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.id").value(migration_history.getId().intValue()))
.andExpect(jsonPath("$.step").value(DEFAULT_STEP.toString()))
.andExpect(jsonPath("$.status").value(DEFAULT_STATUS.toString()))
.andExpect(jsonPath("$.date").value(DEFAULT_DATE.toString()));
}
- @Test
- @Transactional
- public void getNonExistingMigration_history() throws Exception {
- // Get the migration_history
- restMigration_historyMockMvc.perform(get("/api/migration-histories/{id}", Long.MAX_VALUE))
- .andExpect(status().isNotFound());
- }
-
@Test
@Transactional
public void updateMigration_history() throws Exception {
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/StaticExtensionResourceIntTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/StaticExtensionResourceIntTest.java
index 476b9585..0b8b4d32 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/StaticExtensionResourceIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/StaticExtensionResourceIntTest.java
@@ -1,21 +1,19 @@
package fr.yodamad.svn2git.web.rest;
import fr.yodamad.svn2git.Svn2GitApp;
-
import fr.yodamad.svn2git.domain.StaticExtension;
import fr.yodamad.svn2git.repository.StaticExtensionRepository;
import fr.yodamad.svn2git.web.rest.errors.ExceptionTranslator;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;
@@ -23,7 +21,6 @@
import javax.persistence.EntityManager;
import java.util.List;
-
import static fr.yodamad.svn2git.web.rest.TestUtil.createFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
@@ -35,7 +32,7 @@
*
* @see StaticExtensionResource
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class StaticExtensionResourceIntTest {
@@ -67,7 +64,7 @@ public class StaticExtensionResourceIntTest {
private StaticExtension staticExtension;
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
final StaticExtensionResource staticExtensionResource = new StaticExtensionResource(staticExtensionRepository);
@@ -76,6 +73,8 @@ public void setup() {
.setControllerAdvice(exceptionTranslator)
.setConversionService(createFormattingConversionService())
.setMessageConverters(jacksonMessageConverter).build();
+
+ staticExtension = createEntity(em);
}
/**
@@ -92,11 +91,6 @@ public static StaticExtension createEntity(EntityManager em) {
return staticExtension;
}
- @Before
- public void initTest() {
- staticExtension = createEntity(em);
- }
-
@Test
@Transactional
public void createStaticExtension() throws Exception {
@@ -163,13 +157,13 @@ public void getAllStaticExtensions() throws Exception {
// Get all the staticExtensionList
restStaticExtensionMockMvc.perform(get("/api/static-extensions?sort=id,desc"))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(staticExtension.getId().intValue())))
.andExpect(jsonPath("$.[*].value").value(hasItem(DEFAULT_VALUE.toString())))
.andExpect(jsonPath("$.[*].description").value(hasItem(DEFAULT_DESCRIPTION.toString())))
.andExpect(jsonPath("$.[*].enabled").value(hasItem(DEFAULT_ENABLED.booleanValue())));
}
-
+
@Test
@Transactional
public void getStaticExtension() throws Exception {
@@ -179,21 +173,13 @@ public void getStaticExtension() throws Exception {
// Get the staticExtension
restStaticExtensionMockMvc.perform(get("/api/static-extensions/{id}", staticExtension.getId()))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.id").value(staticExtension.getId().intValue()))
.andExpect(jsonPath("$.value").value(DEFAULT_VALUE.toString()))
.andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString()))
.andExpect(jsonPath("$.enabled").value(DEFAULT_ENABLED.booleanValue()));
}
- @Test
- @Transactional
- public void getNonExistingStaticExtension() throws Exception {
- // Get the staticExtension
- restStaticExtensionMockMvc.perform(get("/api/static-extensions/{id}", Long.MAX_VALUE))
- .andExpect(status().isNotFound());
- }
-
@Test
@Transactional
public void updateStaticExtension() throws Exception {
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/StaticMappingResourceIntTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/StaticMappingResourceIntTest.java
index 9a4dcc5d..e58283f8 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/StaticMappingResourceIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/StaticMappingResourceIntTest.java
@@ -1,22 +1,20 @@
package fr.yodamad.svn2git.web.rest;
import fr.yodamad.svn2git.Svn2GitApp;
-
import fr.yodamad.svn2git.domain.StaticMapping;
import fr.yodamad.svn2git.repository.StaticMappingRepository;
import fr.yodamad.svn2git.service.StaticMappingService;
import fr.yodamad.svn2git.web.rest.errors.ExceptionTranslator;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;
@@ -24,7 +22,6 @@
import javax.persistence.EntityManager;
import java.util.List;
-
import static fr.yodamad.svn2git.web.rest.TestUtil.createFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
@@ -36,7 +33,7 @@
*
* @see StaticMappingResource
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class StaticMappingResourceIntTest {
@@ -54,7 +51,7 @@ public class StaticMappingResourceIntTest {
@Autowired
private StaticMappingRepository staticMappingRepository;
-
+
@Autowired
private StaticMappingService staticMappingService;
@@ -74,7 +71,7 @@ public class StaticMappingResourceIntTest {
private StaticMapping staticMapping;
- @Before
+ @BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
final StaticMappingResource staticMappingResource = new StaticMappingResource(staticMappingService);
@@ -83,6 +80,8 @@ public void setup() {
.setControllerAdvice(exceptionTranslator)
.setConversionService(createFormattingConversionService())
.setMessageConverters(jacksonMessageConverter).build();
+
+ staticMapping = createEntity(em);
}
/**
@@ -100,11 +99,6 @@ public static StaticMapping createEntity(EntityManager em) {
return staticMapping;
}
- @Before
- public void initTest() {
- staticMapping = createEntity(em);
- }
-
@Test
@Transactional
public void createStaticMapping() throws Exception {
@@ -154,14 +148,14 @@ public void getAllStaticMappings() throws Exception {
// Get all the staticMappingList
restStaticMappingMockMvc.perform(get("/api/static-mappings?sort=id,desc"))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(staticMapping.getId().intValue())))
.andExpect(jsonPath("$.[*].svnDirectory").value(hasItem(DEFAULT_SVN_DIRECTORY.toString())))
.andExpect(jsonPath("$.[*].regex").value(hasItem(DEFAULT_REGEX.toString())))
.andExpect(jsonPath("$.[*].gitDirectory").value(hasItem(DEFAULT_GIT_DIRECTORY.toString())))
.andExpect(jsonPath("$.[*].svnDirectoryDelete").value(hasItem(DEFAULT_SVN_DIRECTORY_DELETE.booleanValue())));
}
-
+
@Test
@Transactional
public void getStaticMapping() throws Exception {
@@ -171,7 +165,7 @@ public void getStaticMapping() throws Exception {
// Get the staticMapping
restStaticMappingMockMvc.perform(get("/api/static-mappings/{id}", staticMapping.getId()))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.id").value(staticMapping.getId().intValue()))
.andExpect(jsonPath("$.svnDirectory").value(DEFAULT_SVN_DIRECTORY.toString()))
.andExpect(jsonPath("$.regex").value(DEFAULT_REGEX.toString()))
@@ -179,14 +173,6 @@ public void getStaticMapping() throws Exception {
.andExpect(jsonPath("$.svnDirectoryDelete").value(DEFAULT_SVN_DIRECTORY_DELETE.booleanValue()));
}
- @Test
- @Transactional
- public void getNonExistingStaticMapping() throws Exception {
- // Get the staticMapping
- restStaticMappingMockMvc.perform(get("/api/static-mappings/{id}", Long.MAX_VALUE))
- .andExpect(status().isNotFound());
- }
-
@Test
@Transactional
public void updateStaticMapping() throws Exception {
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/SvnResourceTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/SvnResourceTest.java
index 1587f3fc..be11e00c 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/SvnResourceTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/SvnResourceTest.java
@@ -4,20 +4,21 @@
import fr.yodamad.svn2git.data.Repository;
import fr.yodamad.svn2git.domain.SvnInfo;
import fr.yodamad.svn2git.domain.SvnStructure;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.tmatesoft.svn.core.SVNAuthenticationException;
import java.util.List;
import static fr.yodamad.svn2git.data.Repository.Modules.MODULE_1;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class SvnResourceTest {
@@ -26,9 +27,9 @@ public class SvnResourceTest {
public static final Integer DEPTH = 2;
- public SvnInfo svnInfo = new SvnInfo();
+ public static SvnInfo svnInfo = new SvnInfo();
- @Before
+ @BeforeEach
public void initSvnInfo() {
svnInfo = new SvnInfo();
svnInfo.url = "https://chaos.yodamad.fr/svn";
@@ -128,10 +129,13 @@ public void test_svn_listing_with_depth_1() {
});
}
- @Test(expected = SVNAuthenticationException.class)
+ @Test
public void test_invalid_credentials() {
svnInfo.user = "hacker";
svnInfo.password = "hacker";
- svnResource.listSVN(svnInfo, Repository.simple().name, DEPTH);
+
+ assertThrows(SVNAuthenticationException.class, () -> {
+ svnResource.listSVN(svnInfo, Repository.simple().name, DEPTH);
+ });
}
}
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/UserJWTControllerIntTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/UserJWTControllerIntTest.java
index 3e98c2b4..da6a747c 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/UserJWTControllerIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/UserJWTControllerIntTest.java
@@ -6,32 +6,28 @@
import fr.yodamad.svn2git.security.jwt.TokenProvider;
import fr.yodamad.svn2git.web.rest.errors.ExceptionTranslator;
import fr.yodamad.svn2git.web.rest.vm.LoginVM;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;
+import static org.hamcrest.Matchers.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.Matchers.isEmptyString;
-import static org.hamcrest.Matchers.not;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
/**
* Test class for the UserJWTController REST controller.
*
* @see UserJWTController
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class UserJWTControllerIntTest {
@@ -52,7 +48,7 @@ public class UserJWTControllerIntTest {
private MockMvc mockMvc;
- @Before
+ @BeforeEach
public void setup() {
UserJWTController userJWTController = new UserJWTController(tokenProvider, authenticationManager);
this.mockMvc = MockMvcBuilders.standaloneSetup(userJWTController)
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/UserResourceIntTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/UserResourceIntTest.java
index c819ab8c..eb098d7a 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/UserResourceIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/UserResourceIntTest.java
@@ -12,26 +12,29 @@
import fr.yodamad.svn2git.web.rest.errors.ExceptionTranslator;
import fr.yodamad.svn2git.web.rest.vm.ManagedUserVM;
import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.time.Instant;
-import java.util.*;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasItems;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
@@ -40,7 +43,7 @@
*
* @see UserResource
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class UserResourceIntTest {
@@ -95,7 +98,7 @@ public class UserResourceIntTest {
private User user;
- @Before
+ @BeforeEach
public void setup() {
UserResource userResource = new UserResource(userService, userRepository, mailService);
@@ -104,6 +107,10 @@ public void setup() {
.setControllerAdvice(exceptionTranslator)
.setMessageConverters(jacksonMessageConverter)
.build();
+
+ user = createEntity(em);
+ user.setLogin(DEFAULT_LOGIN);
+ user.setEmail(DEFAULT_EMAIL);
}
/**
@@ -125,13 +132,6 @@ public static User createEntity(EntityManager em) {
return user;
}
- @Before
- public void initTest() {
- user = createEntity(em);
- user.setLogin(DEFAULT_LOGIN);
- user.setEmail(DEFAULT_EMAIL);
- }
-
@Test
@Transactional
public void createUser() throws Exception {
@@ -262,7 +262,7 @@ public void getAllUsers() throws Exception {
restUserMockMvc.perform(get("/api/users?sort=id,desc")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.[*].login").value(hasItem(DEFAULT_LOGIN)))
.andExpect(jsonPath("$.[*].firstName").value(hasItem(DEFAULT_FIRSTNAME)))
.andExpect(jsonPath("$.[*].lastName").value(hasItem(DEFAULT_LASTNAME)))
@@ -280,7 +280,7 @@ public void getUser() throws Exception {
// Get the user
restUserMockMvc.perform(get("/api/users/{login}", user.getLogin()))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$.login").value(user.getLogin()))
.andExpect(jsonPath("$.firstName").value(DEFAULT_FIRSTNAME))
.andExpect(jsonPath("$.lastName").value(DEFAULT_LASTNAME))
@@ -289,13 +289,6 @@ public void getUser() throws Exception {
.andExpect(jsonPath("$.langKey").value(DEFAULT_LANGKEY));
}
- @Test
- @Transactional
- public void getNonExistingUser() throws Exception {
- restUserMockMvc.perform(get("/api/users/unknown"))
- .andExpect(status().isNotFound());
- }
-
@Test
@Transactional
public void updateUser() throws Exception {
@@ -486,10 +479,10 @@ public void deleteUser() throws Exception {
@Transactional
public void getAllAuthorities() throws Exception {
restUserMockMvc.perform(get("/api/users/authorities")
- .accept(TestUtil.APPLICATION_JSON_UTF8)
- .contentType(TestUtil.APPLICATION_JSON_UTF8))
+ .accept(MediaType.APPLICATION_JSON_VALUE)
+ .contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(status().isOk())
- .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
+ .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
.andExpect(jsonPath("$").isArray())
.andExpect(jsonPath("$").value(hasItems(AuthoritiesConstants.USER, AuthoritiesConstants.ADMIN)));
}
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/errors/ExceptionTranslatorIntTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/errors/ExceptionTranslatorIntTest.java
index 10e5c92e..50d41b1d 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/errors/ExceptionTranslatorIntTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/errors/ExceptionTranslatorIntTest.java
@@ -1,29 +1,27 @@
package fr.yodamad.svn2git.web.rest.errors;
import fr.yodamad.svn2git.Svn2GitApp;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
/**
* Test class for the ExceptionTranslator controller advice.
*
* @see ExceptionTranslator
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = Svn2GitApp.class)
public class ExceptionTranslatorIntTest {
@@ -38,7 +36,7 @@ public class ExceptionTranslatorIntTest {
private MockMvc mockMvc;
- @Before
+ @BeforeEach
public void setup() {
mockMvc = MockMvcBuilders.standaloneSetup(controller)
.setControllerAdvice(exceptionTranslator)
diff --git a/src/test/java/fr/yodamad/svn2git/web/rest/util/PaginationUtilUnitTest.java b/src/test/java/fr/yodamad/svn2git/web/rest/util/PaginationUtilUnitTest.java
index 03a57e33..ce9bf494 100644
--- a/src/test/java/fr/yodamad/svn2git/web/rest/util/PaginationUtilUnitTest.java
+++ b/src/test/java/fr/yodamad/svn2git/web/rest/util/PaginationUtilUnitTest.java
@@ -1,18 +1,16 @@
package fr.yodamad.svn2git.web.rest.util;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.HttpHeaders;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+
/**
* Tests based on parsing algorithm in app/components/util/pagination-util.service.js
*
diff --git a/src/test/resources/config/application.yml b/src/test/resources/config/application.yml
index b6411985..774df3cc 100644
--- a/src/test/resources/config/application.yml
+++ b/src/test/resources/config/application.yml
@@ -26,7 +26,7 @@ spring:
hikari:
auto-commit: false
jpa:
- database-platform: io.github.jhipster.domain.util.FixedH2Dialect
+ database-platform: tech.jhipster.domain.util.FixedH2Dialect
database: H2
open-in-view: false
show-sql: false
@@ -91,10 +91,6 @@ jhipster:
base-64-secret: MWU2ZWM1ZDEyM2MxZWRjNzJmMDQ1YTJkNzYzYzM3MWRkYTliMWYyNWRjMDMzOTVmNzYxNmQ2NDAyMTA1Y2IwODAyZWFkNmIzMjM1ODA5YzFhM2NjYmU0MzNkZDk5YmJkMTM2M2Y5MmEyYTAzZTY1YTgzMzY3NTdmOWY0MTYxM2U=
# Token is valid 24 hours
token-validity-in-seconds: 86400
- metrics: # DropWizard Metrics configuration, used by MetricsConfiguration
- logs: # Reports Dropwizard metrics in the logs
- enabled: true
- report-frequency: 60 # in seconds
# ===================================================================
# Application specific properties
diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml
index eede9a06..cb5e4b58 100644
--- a/src/test/resources/logback.xml
+++ b/src/test/resources/logback.xml
@@ -6,7 +6,7 @@
-
+