From 68ccb25307b9c77843a9e7e5425aa13ea062af30 Mon Sep 17 00:00:00 2001 From: Julien Dubois Date: Tue, 30 Jun 2015 19:50:50 +0200 Subject: [PATCH] Release v2.17.0 --- Gruntfile.js | 23 +- bower.json | 1 - package.json | 2 +- pom.xml | 31 +- .../java/com/mycompany/myapp/Application.java | 2 +- .../myapp/config/SecurityConfiguration.java | 8 +- .../config/apidoc/SwaggerConfiguration.java | 43 +-- .../metrics/DatabaseHealthIndicator.java | 3 - .../util/ISO8601LocalDateDeserializer.java | 2 +- .../myapp/web/rest/util/PaginationUtil.java | 2 +- .../resources/config/application-prod.yml | 2 +- src/main/resources/config/application.yml | 1 + src/main/resources/logback.xml | 3 +- src/main/webapp/i18n/en/global.json | 3 + src/main/webapp/i18n/fr/global.json | 5 +- src/main/webapp/i18n/fr/health.json | 9 +- .../app/account/settings/settings.html | 2 +- .../webapp/scripts/app/admin/docs/docs.html | 2 +- src/main/webapp/scripts/app/app.js | 3 +- .../language/language.controller.js | 24 ++ .../scripts/components/navbar/navbar.html | 2 +- .../account/health/healthControllerSpec.js | 301 ------------------ .../app/account/login/loginControllerSpec.js | 20 -- .../password/password.directive.spec.js | 1 - .../password/passwordControllerSpec.js | 54 ---- .../account/password/passwordDirectiveSpec.js | 74 ----- .../sessions/sessionsControllerSpec.js | 37 --- .../settings/settingsControllerSpec.js | 56 ---- .../components/auth/auth.services.spec.js | 1 - .../spec/components/auth/authServicesSpec.js | 49 --- src/test/resources/config/application.yml | 1 + 31 files changed, 107 insertions(+), 660 deletions(-) delete mode 100644 src/test/javascript/spec/app/account/health/healthControllerSpec.js delete mode 100644 src/test/javascript/spec/app/account/login/loginControllerSpec.js delete mode 100644 src/test/javascript/spec/app/account/password/passwordControllerSpec.js delete mode 100644 src/test/javascript/spec/app/account/password/passwordDirectiveSpec.js delete mode 100644 src/test/javascript/spec/app/account/sessions/sessionsControllerSpec.js delete mode 100644 src/test/javascript/spec/app/account/settings/settingsControllerSpec.js delete mode 100644 src/test/javascript/spec/components/auth/authServicesSpec.js diff --git a/Gruntfile.js b/Gruntfile.js index 0b20d3bb4..493cc7092 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,4 +1,4 @@ -// Generated on 2015-06-17 using generator-jhipster 2.16.1 +// Generated on 2015-06-30 using generator-jhipster 2.17.0 'use strict'; var fs = require('fs'); @@ -52,13 +52,12 @@ module.exports = function (grunt) { app: { src: ['src/main/webapp/index.html'], exclude: [ - /angular-i18n/, // localizations are loaded dynamically - /swagger-ui/ + /angular-i18n/ // localizations are loaded dynamically ] }, test: { src: 'src/test/javascript/karma.conf.js', - exclude: [/angular-i18n/, /swagger-ui/, /angular-scenario/], + exclude: [/angular-i18n/, /angular-scenario/], ignorePath: /\.\.\/\.\.\//, // remove ../../ from paths of injected javascripts devDependencies: true, fileTypes: { @@ -184,9 +183,6 @@ module.exports = function (grunt) { } }, cssmin: { - options: { - root: 'src/main/webapp' // Replace relative paths for static resources with absolute path - } // src and dest is configured in a subtask called "generated" by usemin }, ngtemplates: { @@ -235,6 +231,18 @@ module.exports = function (grunt) { }, // Put files not handled in other tasks here copy: { + fonts: { + files: [{ + expand: true, + dot: true, + flatten: true, + cwd: 'src/main/webapp', + dest: '<%= yeoman.dist %>/assets/fonts', + src: [ + 'bower_components/bootstrap/fonts/*.*' + ] + }] + }, dist: { files: [{ expand: true, @@ -352,6 +360,7 @@ module.exports = function (grunt) { 'imagemin', 'svgmin', 'concat', + 'copy:fonts', 'copy:dist', 'ngAnnotate', 'cssmin', diff --git a/bower.json b/bower.json index 144c6cc2e..d34a63993 100644 --- a/bower.json +++ b/bower.json @@ -19,7 +19,6 @@ "angular-translate-loader-partial": "2.7.0", "angular-dynamic-locale": "0.1.27", "angular-local-storage": "0.2.0", - "swagger-ui": "2.0.24", "angular-cache-buster": "0.4.3", "ngInfiniteScroll": "1.2.0" }, diff --git a/package.json b/package.json index 699642aad..9a4be4dbe 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "karma-phantomjs-launcher": "0.2.0", "phantomjs": "1.9.17", "karma": "0.12.35", - "generator-jhipster": "2.16.1", + "generator-jhipster": "2.17.0", "lodash": "3.3.1", "xml2js": "0.4.5", "yo": ">=1.3.0", diff --git a/pom.xml b/pom.xml index d6283aa91..1fcca79cc 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,7 @@ 3.3.2 1.2.1 3.5 - 1.0.0.Beta4 + 1.0.0.CR1 yyyyMMddHHmmss 1.3.1 2.3.0 @@ -46,8 +46,8 @@ 3.0.4 false 2.3 - 4.0.0.RELEASE - 0.9.5 + 4.0.1.RELEASE + 2.0.3 3.2.0.GA @@ -136,23 +136,14 @@ test - com.mangofactory - swagger-springmvc - ${swagger-springmvc.version} - - - jackson-module-scala_2.10 - com.fasterxml.jackson.module - - - scalap - org.scala-lang - - - scala-compiler - org.scala-lang - - + io.springfox + springfox-swagger-ui + ${springfox.version} + + + io.springfox + springfox-swagger2 + ${springfox.version} com.mattbertolini diff --git a/src/main/java/com/mycompany/myapp/Application.java b/src/main/java/com/mycompany/myapp/Application.java index 219c6d602..9c634c6ef 100644 --- a/src/main/java/com/mycompany/myapp/Application.java +++ b/src/main/java/com/mycompany/myapp/Application.java @@ -44,7 +44,7 @@ public void initApplication() throws IOException { log.warn("No Spring profile configured, running with default configuration"); } else { log.info("Running with Spring profile(s) : {}", Arrays.toString(env.getActiveProfiles())); - Collection activeProfiles = Arrays.asList(env.getActiveProfiles()); + Collection activeProfiles = Arrays.asList(env.getActiveProfiles()); if (activeProfiles.contains("dev") && activeProfiles.contains("prod")) { log.error("You have misconfigured your application! " + "It should not run with both the 'dev' and 'prod' profiles at the same time."); diff --git a/src/main/java/com/mycompany/myapp/config/SecurityConfiguration.java b/src/main/java/com/mycompany/myapp/config/SecurityConfiguration.java index 2966830fd..9dca806d1 100644 --- a/src/main/java/com/mycompany/myapp/config/SecurityConfiguration.java +++ b/src/main/java/com/mycompany/myapp/config/SecurityConfiguration.java @@ -72,7 +72,7 @@ public void configure(WebSecurity web) throws Exception { .antMatchers("/bower_components/**") .antMatchers("/i18n/**") .antMatchers("/assets/**") - .antMatchers("/swagger-ui/**") + .antMatchers("/swagger-ui.html") .antMatchers("/test/**") .antMatchers("/console/**"); } @@ -118,6 +118,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers("/api/account/reset_password/finish").permitAll() .antMatchers("/api/logs/**").hasAuthority(AuthoritiesConstants.ADMIN) .antMatchers("/api/**").authenticated() + .antMatchers("/webjars/**").permitAll() .antMatchers("/metrics/**").hasAuthority(AuthoritiesConstants.ADMIN) .antMatchers("/health/**").hasAuthority(AuthoritiesConstants.ADMIN) .antMatchers("/trace/**").hasAuthority(AuthoritiesConstants.ADMIN) @@ -129,7 +130,10 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers("/autoconfig/**").hasAuthority(AuthoritiesConstants.ADMIN) .antMatchers("/env/**").hasAuthority(AuthoritiesConstants.ADMIN) .antMatchers("/trace/**").hasAuthority(AuthoritiesConstants.ADMIN) - .antMatchers("/api-docs/**").hasAuthority(AuthoritiesConstants.ADMIN) + .antMatchers("/v2/api-docs/**").hasAuthority(AuthoritiesConstants.ADMIN) + .antMatchers("/configuration/security").hasAuthority(AuthoritiesConstants.ADMIN) + .antMatchers("/configuration/ui").hasAuthority(AuthoritiesConstants.ADMIN) + .antMatchers("/swagger-ui.html").hasAuthority(AuthoritiesConstants.ADMIN) .antMatchers("/protected/**").authenticated(); } diff --git a/src/main/java/com/mycompany/myapp/config/apidoc/SwaggerConfiguration.java b/src/main/java/com/mycompany/myapp/config/apidoc/SwaggerConfiguration.java index 6fdcac3fa..1930e52b3 100644 --- a/src/main/java/com/mycompany/myapp/config/apidoc/SwaggerConfiguration.java +++ b/src/main/java/com/mycompany/myapp/config/apidoc/SwaggerConfiguration.java @@ -1,10 +1,6 @@ package com.mycompany.myapp.config.apidoc; import com.mycompany.myapp.config.Constants; -import com.mangofactory.swagger.configuration.SpringSwaggerConfig; -import com.mangofactory.swagger.models.dto.ApiInfo; -import com.mangofactory.swagger.plugin.EnableSwagger; -import com.mangofactory.swagger.plugin.SwaggerSpringMvcPlugin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.bind.RelaxedPropertyResolver; @@ -15,17 +11,23 @@ import org.springframework.core.env.Environment; import org.springframework.http.ResponseEntity; import org.springframework.util.StopWatch; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +import static springfox.documentation.builders.PathSelectors.regex; /** - * Swagger configuration. + * Springfox Swagger configuration. * - * Warning! When having a lot of REST endpoints, Swagger can become a performance issue. In that + * Warning! When having a lot of REST endpoints, Springfox can become a performance issue. In that * case, you can use a specific Spring profile for this class, so that only front-end developers * have access to the Swagger view. */ @Configuration -@EnableSwagger -@Profile("!" + Constants.SPRING_PROFILE_FAST) +@EnableSwagger2 +@Profile("!"+Constants.SPRING_PROFILE_PRODUCTION) public class SwaggerConfiguration implements EnvironmentAware { private final Logger log = LoggerFactory.getLogger(SwaggerConfiguration.class); @@ -40,19 +42,19 @@ public void setEnvironment(Environment environment) { } /** - * Swagger Spring MVC configuration. + * Swagger Springfox configuration. */ @Bean - public SwaggerSpringMvcPlugin swaggerSpringMvcPlugin(SpringSwaggerConfig springSwaggerConfig) { + public Docket swaggerSpringfoxDocket() { log.debug("Starting Swagger"); StopWatch watch = new StopWatch(); watch.start(); - SwaggerSpringMvcPlugin swaggerSpringMvcPlugin = new SwaggerSpringMvcPlugin(springSwaggerConfig) + Docket swaggerSpringMvcPlugin = new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .genericModelSubstitutes(ResponseEntity.class) - .includePatterns(DEFAULT_INCLUDE_PATTERN); - - swaggerSpringMvcPlugin.build(); + .select() + .paths(regex(DEFAULT_INCLUDE_PATTERN)) // and by paths + .build(); watch.stop(); log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis()); return swaggerSpringMvcPlugin; @@ -63,11 +65,12 @@ public SwaggerSpringMvcPlugin swaggerSpringMvcPlugin(SpringSwaggerConfig springS */ private ApiInfo apiInfo() { return new ApiInfo( - propertyResolver.getProperty("title"), - propertyResolver.getProperty("description"), - propertyResolver.getProperty("termsOfServiceUrl"), - propertyResolver.getProperty("contact"), - propertyResolver.getProperty("license"), - propertyResolver.getProperty("licenseUrl")); + propertyResolver.getProperty("title"), + propertyResolver.getProperty("description"), + propertyResolver.getProperty("version"), + propertyResolver.getProperty("termsOfServiceUrl"), + propertyResolver.getProperty("contact"), + propertyResolver.getProperty("license"), + propertyResolver.getProperty("licenseUrl")); } } diff --git a/src/main/java/com/mycompany/myapp/config/metrics/DatabaseHealthIndicator.java b/src/main/java/com/mycompany/myapp/config/metrics/DatabaseHealthIndicator.java index 4e909df4d..1831a742f 100644 --- a/src/main/java/com/mycompany/myapp/config/metrics/DatabaseHealthIndicator.java +++ b/src/main/java/com/mycompany/myapp/config/metrics/DatabaseHealthIndicator.java @@ -15,8 +15,6 @@ */ public class DatabaseHealthIndicator extends AbstractHealthIndicator { - private DataSource dataSource; - private JdbcTemplate jdbcTemplate; private static Map queries = new HashMap<>(); @@ -36,7 +34,6 @@ public class DatabaseHealthIndicator extends AbstractHealthIndicator { private String query = null; public DatabaseHealthIndicator(DataSource dataSource) { - this.dataSource = dataSource; this.jdbcTemplate = new JdbcTemplate(dataSource); } diff --git a/src/main/java/com/mycompany/myapp/domain/util/ISO8601LocalDateDeserializer.java b/src/main/java/com/mycompany/myapp/domain/util/ISO8601LocalDateDeserializer.java index e6224cc6d..7ec9d4295 100644 --- a/src/main/java/com/mycompany/myapp/domain/util/ISO8601LocalDateDeserializer.java +++ b/src/main/java/com/mycompany/myapp/domain/util/ISO8601LocalDateDeserializer.java @@ -21,7 +21,7 @@ public LocalDate deserialize(JsonParser jp, DeserializationContext ctxt) JsonToken t = jp.getCurrentToken(); if (t == JsonToken.VALUE_STRING) { String str = jp.getText().trim(); - return ISODateTimeFormat.dateTimeParser().parseLocalDate(str); + return ISODateTimeFormat.dateTimeParser().parseDateTime(str).toLocalDate(); } if (t == JsonToken.VALUE_NUMBER_INT) { return new LocalDate(jp.getLongValue()); diff --git a/src/main/java/com/mycompany/myapp/web/rest/util/PaginationUtil.java b/src/main/java/com/mycompany/myapp/web/rest/util/PaginationUtil.java index 8e1b03223..b550d6e6a 100644 --- a/src/main/java/com/mycompany/myapp/web/rest/util/PaginationUtil.java +++ b/src/main/java/com/mycompany/myapp/web/rest/util/PaginationUtil.java @@ -36,7 +36,7 @@ public static Pageable generatePageRequest(Integer offset, Integer limit) { return new PageRequest(offset - 1, limit); } - public static HttpHeaders generatePaginationHttpHeaders(Page page, String baseUrl, Integer offset, Integer limit) + public static HttpHeaders generatePaginationHttpHeaders(Page page, String baseUrl, Integer offset, Integer limit) throws URISyntaxException { if (offset == null || offset < MIN_OFFSET) { diff --git a/src/main/resources/config/application-prod.yml b/src/main/resources/config/application-prod.yml index 3db64e8c1..4dceeb2b4 100644 --- a/src/main/resources/config/application-prod.yml +++ b/src/main/resources/config/application-prod.yml @@ -9,7 +9,7 @@ spring: active: prod datasource: dataSourceClassName: com.mysql.jdbc.jdbc2.optional.MysqlDataSource - url: jdbc:mysql://localhost:3306/jhipster + url: jdbc:mysql://localhost:3306/jhipster?useUnicode=true&characterEncoding=utf8 databaseName: serverName: username: root diff --git a/src/main/resources/config/application.yml b/src/main/resources/config/application.yml index ca58e8ba0..eea8ba904 100644 --- a/src/main/resources/config/application.yml +++ b/src/main/resources/config/application.yml @@ -27,6 +27,7 @@ mail: swagger: title: jhipster API description: jhipster applications and beyond! + version: 0.0.1 termsOfServiceUrl: http://jhipster.github.io/ contact: license: Apache 2.0 diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml index 492a11e7b..1b5f6d6ef 100644 --- a/src/main/resources/logback.xml +++ b/src/main/resources/logback.xml @@ -51,8 +51,7 @@ - - + diff --git a/src/main/webapp/i18n/en/global.json b/src/main/webapp/i18n/en/global.json index df878854f..0bd55e2f2 100644 --- a/src/main/webapp/i18n/en/global.json +++ b/src/main/webapp/i18n/en/global.json @@ -67,6 +67,9 @@ "maxlength": "Your e-mail cannot be longer than 50 characters." } } + }, + "field": { + "id" : "ID" } }, "entity": { diff --git a/src/main/webapp/i18n/fr/global.json b/src/main/webapp/i18n/fr/global.json index 03f3d55ee..fef634cc1 100644 --- a/src/main/webapp/i18n/fr/global.json +++ b/src/main/webapp/i18n/fr/global.json @@ -67,6 +67,9 @@ "invalid": "Votre email n'est pas valide." } } + }, + "field": { + "id" : "ID" } }, "entity": { @@ -91,7 +94,7 @@ "maxlength": "Ce champs doit faire moins de {{max}} caractères.", "min": "Ce champs doit être inférieur à {{min}}.", "max": "Ce champs doit être supérieur à {{max}}.", - "pattern": "Ce champs doit suivre l'expression régluière {{pattern}}.", + "pattern": "Ce champs doit suivre l'expression régulière {{pattern}}.", "number": "Ce champs doit être un nombre.", "datetimelocal": "Ce champs doit être une date et une heure." } diff --git a/src/main/webapp/i18n/fr/health.json b/src/main/webapp/i18n/fr/health.json index 5f5a80429..f9449deae 100644 --- a/src/main/webapp/i18n/fr/health.json +++ b/src/main/webapp/i18n/fr/health.json @@ -2,12 +2,19 @@ "health": { "title": "Diagnostics", "refresh.button": "Rafraichir", + "stacktrace": "Stacktrace", + "details": { + "details": "Détails", + "properties": "Propriétés", + "name": "Nom", + "value": "Valeur", + "error": "Erreur" + }, "indicator": { "diskSpace": "Espace disque", "mail": "Email", "db": "Base de données" }, - "stacktrace": "Stacktrace", "table": { "service": "Nom du service", "status": "Etat" diff --git a/src/main/webapp/scripts/app/account/settings/settings.html b/src/main/webapp/scripts/app/account/settings/settings.html index d6ff2a759..3844c7273 100644 --- a/src/main/webapp/scripts/app/account/settings/settings.html +++ b/src/main/webapp/scripts/app/account/settings/settings.html @@ -80,7 +80,7 @@

- + diff --git a/src/main/webapp/scripts/app/admin/docs/docs.html b/src/main/webapp/scripts/app/admin/docs/docs.html index 24ab028f4..42d2bf429 100644 --- a/src/main/webapp/scripts/app/admin/docs/docs.html +++ b/src/main/webapp/scripts/app/admin/docs/docs.html @@ -1,2 +1,2 @@ - diff --git a/src/main/webapp/scripts/app/app.js b/src/main/webapp/scripts/app/app.js index 712ab4233..fe9579433 100644 --- a/src/main/webapp/scripts/app/app.js +++ b/src/main/webapp/scripts/app/app.js @@ -53,7 +53,7 @@ angular.module('jhipsterApp', ['LocalStorageModule', 'tmh.dynamicLocale', 'pasca responseError: function(response) { // If we have an unauthorized request we redirect to the login page // Don't do this check on the account API to avoid infinite loop - if (response.status == 401 && response.data.path!="/api/account"){ + if (response.status == 401 && response.data.path !== undefined && response.data.path.indexOf("/api/account") == -1){ var Auth = $injector.get('Auth'); var $state = $injector.get('$state'); var to = $rootScope.toState; @@ -93,7 +93,6 @@ angular.module('jhipsterApp', ['LocalStorageModule', 'tmh.dynamicLocale', 'pasca ], translatePartialLoader: ['$translate', '$translatePartialLoader', function ($translate, $translatePartialLoader) { $translatePartialLoader.addPart('global'); - $translatePartialLoader.addPart('language'); }] } }); diff --git a/src/main/webapp/scripts/components/language/language.controller.js b/src/main/webapp/scripts/components/language/language.controller.js index f1fda600d..eb3924c5f 100644 --- a/src/main/webapp/scripts/components/language/language.controller.js +++ b/src/main/webapp/scripts/components/language/language.controller.js @@ -10,4 +10,28 @@ angular.module('jhipsterApp') Language.getAll().then(function (languages) { $scope.languages = languages; }); + }) + .filter('findLanguageFromKey', function () { + return function (lang) { + return { + "en": "English", + "fr": "Français", + "de": "Deutsch", + "it": "Italiano", + "ru": "Русский", + "tr": "Türkçe", + "ca": "Català", + "da": "Dansk", + "es": "Español", + "hu": "Magyar", + "ja": "日本語", + "kr": "한국어", + "pl": "Polski", + "pt-br": "Português (Brasil)", + "ro": "Română", + "sv": "Svenska", + "zh-cn": "中文(简体)", + "zh-tw": "繁體中文", + }[lang]; + } }); diff --git a/src/main/webapp/scripts/components/navbar/navbar.html b/src/main/webapp/scripts/components/navbar/navbar.html index 9ea8e9015..31ec187fe 100644 --- a/src/main/webapp/scripts/components/navbar/navbar.html +++ b/src/main/webapp/scripts/components/navbar/navbar.html @@ -92,7 +92,7 @@ diff --git a/src/test/javascript/spec/app/account/health/healthControllerSpec.js b/src/test/javascript/spec/app/account/health/healthControllerSpec.js deleted file mode 100644 index 1d62718ca..000000000 --- a/src/test/javascript/spec/app/account/health/healthControllerSpec.js +++ /dev/null @@ -1,301 +0,0 @@ -'use strict'; - -describe('Controllers Tests ', function () { - - beforeEach(module('jhipsterApp')); - - describe('HealthController', function () { - var $scope; - - beforeEach(inject(function ($rootScope, $controller) { - $scope = $rootScope.$new(); - $controller('HealthController', { $scope: $scope }); - })); - - describe('isHealthObject and hasSubSystem', function () { - it('should verify empty object is not a health property leaf', function () { - expect($scope.isHealthObject({})).toBe(false); - expect($scope.hasSubSystem({})).toBe(false); - }); - - it('should verify object with property status and no subsystems is a health property leaf', function () { - var healthObject = { - 'status': 'UP' - }; - expect($scope.isHealthObject(healthObject)).toBe(true); - expect($scope.hasSubSystem(healthObject)).toBe(false); - }); - - it('should verify that object property status and unrecognized objects is a health property leaf', function () { - var healthObject = { - 'status': 'UP', - 'subsystem': { - 'hello': 'UP' - } - }; - expect($scope.isHealthObject(healthObject)).toBe(true); - expect($scope.hasSubSystem(healthObject)).toBe(false); - }); - - it('should verify object with property status but with subsystems is NOT a health property leaf', function () { - var healthObject = { - 'status': 'UP', - 'subsystem': { - 'status': 'UP' - } - }; - expect($scope.isHealthObject(healthObject)).toBe(true); - expect($scope.hasSubSystem(healthObject)).toBe(true); - }); - - }); - - describe('transformHealthData', function () { - it('should flatten empty health data', function () { - var data = {}; - var expected = []; - expect($scope.transformHealthData(data)).toEqual(expected); - }); - - it('should flatten health data with no subsystems', function () { - var data = { - 'status': 'UP', - 'db': { - 'status': 'UP', - 'database': 'H2', - 'hello': '1' - }, - 'mail': { - 'status': 'UP', - 'error': 'mail.a.b.c' - } - }; - var expected = [ - { - 'name': 'db', - 'status': 'UP', - 'details': { - 'database': 'H2', - 'hello': '1' - } - }, - { - 'name': 'mail', - 'status': 'UP', - 'error': 'mail.a.b.c' - } - ]; - expect($scope.transformHealthData(data)).toEqual(expected); - }); - - it('should flatten health data with subsystems at level 1, main system has no additional information', function () { - var data = { - 'status': 'UP', - 'db': { - 'status': 'UP', - 'database': 'H2', - 'hello': '1' - }, - 'mail': { - 'status': 'UP', - 'error': 'mail.a.b.c' - }, - 'system': { - 'status': 'DOWN', - 'subsystem1': { - 'status': 'UP', - 'property1': 'system.subsystem1.property1' - }, - 'subsystem2': { - 'status': 'DOWN', - 'error': 'system.subsystem1.error', - 'property2': 'system.subsystem2.property2' - } - } - }; - var expected = [ - { - 'name': 'db', - 'status': 'UP', - 'details': { - 'database': 'H2', - 'hello': '1' - } - }, - { - 'name': 'mail', - 'status': 'UP', - 'error': 'mail.a.b.c' - }, - { - 'name': 'system.subsystem1', - 'status': 'UP', - 'details': { - 'property1': 'system.subsystem1.property1' - } - }, - { - 'name': 'system.subsystem2', - 'status': 'DOWN', - 'error': 'system.subsystem1.error', - 'details': { - 'property2': 'system.subsystem2.property2' - } - } - ]; - expect($scope.transformHealthData(data)).toEqual(expected); - }); - - it('should flatten health data with subsystems at level 1, main system has additional information', function () { - var data = { - 'status': 'UP', - 'db': { - 'status': 'UP', - 'database': 'H2', - 'hello': '1' - }, - 'mail': { - 'status': 'UP', - 'error': 'mail.a.b.c' - }, - 'system': { - 'status': 'DOWN', - 'property1': 'system.property1', - 'subsystem1': { - 'status': 'UP', - 'property1': 'system.subsystem1.property1' - }, - 'subsystem2': { - 'status': 'DOWN', - 'error': 'system.subsystem1.error', - 'property2': 'system.subsystem2.property2' - } - } - }; - var expected = [ - { - 'name': 'db', - 'status': 'UP', - 'details': { - 'database': 'H2', - 'hello': '1' - } - }, - { - 'name': 'mail', - 'status': 'UP', - 'error': 'mail.a.b.c' - }, - { - 'name': 'system', - 'status': 'DOWN', - 'details': { - 'property1': 'system.property1' - } - }, - { - 'name': 'system.subsystem1', - 'status': 'UP', - 'details': { - 'property1': 'system.subsystem1.property1' - } - }, - { - 'name': 'system.subsystem2', - 'status': 'DOWN', - 'error': 'system.subsystem1.error', - 'details': { - 'property2': 'system.subsystem2.property2' - } - } - ]; - expect($scope.transformHealthData(data)).toEqual(expected); - }); - - it('should flatten health data with subsystems at level 1, main system has additional error', function () { - var data = { - 'status': 'UP', - 'db': { - 'status': 'UP', - 'database': 'H2', - 'hello': '1' - }, - 'mail': { - 'status': 'UP', - 'error': 'mail.a.b.c' - }, - 'system': { - 'status': 'DOWN', - 'error': 'show me', - 'subsystem1': { - 'status': 'UP', - 'property1': 'system.subsystem1.property1' - }, - 'subsystem2': { - 'status': 'DOWN', - 'error': 'system.subsystem1.error', - 'property2': 'system.subsystem2.property2' - } - } - }; - var expected = [ - { - 'name': 'db', - 'status': 'UP', - 'details': { - 'database': 'H2', - 'hello': '1' - } - }, - { - 'name': 'mail', - 'status': 'UP', - 'error': 'mail.a.b.c' - }, - { - 'name': 'system', - 'status': 'DOWN', - 'error': 'show me' - }, - { - 'name': 'system.subsystem1', - 'status': 'UP', - 'details': { - 'property1': 'system.subsystem1.property1' - } - }, - { - 'name': 'system.subsystem2', - 'status': 'DOWN', - 'error': 'system.subsystem1.error', - 'details': { - 'property2': 'system.subsystem2.property2' - } - } - ]; - expect($scope.transformHealthData(data)).toEqual(expected); - }); - }); - - describe('getModuleName(path, name)', function () { - it('should show both path and name if defined', function () { - expect($scope.getModuleName('path', 'name')).toEqual('path' + $scope.separator + 'name'); - }); - - it('should show only path if name is not defined', function () { - expect($scope.getModuleName('path')).toEqual('path'); - expect($scope.getModuleName('path', '')).toEqual('path'); - expect($scope.getModuleName('path', null)).toEqual('path'); - }); - - it('should show only name if path is not defined', function () { - expect($scope.getModuleName(null, 'name')).toEqual('name'); - expect($scope.getModuleName('', 'name')).toEqual('name'); - }); - - it('should show empty string if neither name nor path is defined', function () { - expect($scope.getModuleName()).toEqual(''); - }); - }); - }); -}); diff --git a/src/test/javascript/spec/app/account/login/loginControllerSpec.js b/src/test/javascript/spec/app/account/login/loginControllerSpec.js deleted file mode 100644 index 2f85d2800..000000000 --- a/src/test/javascript/spec/app/account/login/loginControllerSpec.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -describe('Controllers Tests ', function () { - - beforeEach(module('jhipsterApp')); - - describe('LoginController', function () { - var $scope; - - - beforeEach(inject(function ($rootScope, $controller) { - $scope = $rootScope.$new(); - $controller('LoginController', {$scope: $scope}); - })); - - it('should set remember Me', function () { - expect($scope.rememberMe).toBeTruthy(); - }); - }); -}); diff --git a/src/test/javascript/spec/app/account/password/password.directive.spec.js b/src/test/javascript/spec/app/account/password/password.directive.spec.js index 12849b995..bedd2460b 100644 --- a/src/test/javascript/spec/app/account/password/password.directive.spec.js +++ b/src/test/javascript/spec/app/account/password/password.directive.spec.js @@ -18,7 +18,6 @@ describe('Directive Tests ', function () { $httpBackend.expectGET('scripts/components/navbar/navbar.html').respond({}); $httpBackend.expectGET('i18n/en/global.json').respond({}); - $httpBackend.expectGET('i18n/en/language.json').respond({}); $httpBackend.expectGET('i18n/en/main.json').respond({}); $httpBackend.expectGET('scripts/app/main/main.html').respond({}); diff --git a/src/test/javascript/spec/app/account/password/passwordControllerSpec.js b/src/test/javascript/spec/app/account/password/passwordControllerSpec.js deleted file mode 100644 index 77483b035..000000000 --- a/src/test/javascript/spec/app/account/password/passwordControllerSpec.js +++ /dev/null @@ -1,54 +0,0 @@ -'use strict'; - -describe('Controllers Tests ', function () { - - beforeEach(module('jhipsterApp')); - - var $scope, $httpBackend, q, Auth; - - // define the mock Auth service - beforeEach(function() { - Auth = { - changePassword: function() {} - }; - }); - - beforeEach(inject(function ($rootScope, $controller, $q, $injector) { - $scope = $rootScope.$new(); - q = $q; - $httpBackend = $injector.get('$httpBackend'); - $controller('PasswordController', {$scope: $scope, Auth: Auth}); - })); - - describe('PasswordController', function () { - it('should show error if passwords do not match', function () { - //GIVEN - $scope.password = 'password1'; - $scope.confirmPassword = 'password2'; - //WHEN - $scope.changePassword(); - //THEN - expect($scope.doNotMatch).toBe('ERROR'); - }); - it('should call Service and set OK on Success', function () { - //GIVEN - var pass = 'myPassword'; - $scope.password = pass; - $scope.confirmPassword = pass; - - spyOn(Auth, 'changePassword').and.returnValue(new function(){ - var deferred = q.defer(); - $scope.error = null; - $scope.success = 'OK'; - return deferred.promise; - }); - - //WHEN - $scope.changePassword(); - - //THEN - expect($scope.error).toBeNull(); - expect($scope.success).toBe('OK'); - }); - }); -}); diff --git a/src/test/javascript/spec/app/account/password/passwordDirectiveSpec.js b/src/test/javascript/spec/app/account/password/passwordDirectiveSpec.js deleted file mode 100644 index a82642381..000000000 --- a/src/test/javascript/spec/app/account/password/passwordDirectiveSpec.js +++ /dev/null @@ -1,74 +0,0 @@ -'use strict'; - -describe('Directive Tests ', function () { - - beforeEach(module('jhipsterApp')); - - var elm, scope, $httpBackend; - - beforeEach(inject(function($compile, $rootScope, $injector) { - $httpBackend = $injector.get('$httpBackend'); - - var html = ''; - scope = $rootScope.$new(); - elm = angular.element(html); - $compile(elm)(scope); - - $httpBackend.expectGET(/api\/account\?cacheBuster=\d+/).respond({}); - $httpBackend.expectGET('scripts/components/navbar/navbar.html').respond({}); - $httpBackend.expectGET('i18n/en/global.json').respond({}); - $httpBackend.expectGET('i18n/en/language.json').respond({}); - $httpBackend.expectGET('i18n/en/main.json').respond({}); - $httpBackend.expectGET('scripts/app/main/main.html').respond({}); - })); - - afterEach(function() { - $httpBackend.flush(); - $httpBackend.verifyNoOutstandingExpectation(); - $httpBackend.verifyNoOutstandingRequest(); - }); - - describe('Password strength', function () { - it("Should display the password strength bar", function() { - expect(elm.find('ul').length).toEqual(1); - expect(elm.find('li').length).toEqual(5); - }); - - it("Should change the first 2 points of the strength bar", function() { - scope.$apply(function() { - scope.password = "morethan5chars"; // that should trigger the 2 first points - }); - - var firstpointStyle = elm.find('ul').children('li')[0].getAttribute('style'); - expect(firstpointStyle).toContain('background-color: rgb(255, 153, 0)'); - - var secondpointStyle = elm.find('ul').children('li')[1].getAttribute('style'); - expect(secondpointStyle).toContain('background-color: rgb(255, 153, 0)'); - - var thirdpointStyle = elm.find('ul').children('li')[2].getAttribute('style'); - expect(thirdpointStyle).toContain('background-color: rgb(221, 221, 221)'); - }); - - it("Should change the first 4 points of the strength bar", function() { - scope.$apply(function() { - scope.password = "mo5ch$=!"; // that should trigger the 3 first points - }); - - var firstpointStyle = elm.find('ul').children('li')[0].getAttribute('style'); - dump(firstpointStyle); - expect(firstpointStyle).toContain('background-color: rgb(153, 255, 0)'); - - var secondpointStyle = elm.find('ul').children('li')[1].getAttribute('style'); - expect(secondpointStyle).toContain('background-color: rgb(153, 255, 0)'); - - var thirdpointStyle = elm.find('ul').children('li')[2].getAttribute('style'); - expect(thirdpointStyle).toContain('background-color: rgb(153, 255, 0)'); - - var fourthpointStyle = elm.find('ul').children('li')[3].getAttribute('style'); - expect(fourthpointStyle).toContain('background-color: rgb(153, 255, 0)'); - - var fifthpointStyle = elm.find('ul').children('li')[4].getAttribute('style'); - expect(fifthpointStyle).toContain('background-color: rgb(221, 221, 221)'); - }); - }); -}); diff --git a/src/test/javascript/spec/app/account/sessions/sessionsControllerSpec.js b/src/test/javascript/spec/app/account/sessions/sessionsControllerSpec.js deleted file mode 100644 index ac0be2625..000000000 --- a/src/test/javascript/spec/app/account/sessions/sessionsControllerSpec.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -describe('Controllers Tests ', function () { - - beforeEach(module('jhipsterApp')); - - describe('SessionsController', function () { - var $scope, SessionsService; - - beforeEach(inject(function ($rootScope, $controller, Sessions) { - $scope = $rootScope.$new(); - - SessionsService = Sessions; - $controller('SessionsController',{$scope:$scope, Sessions:SessionsService}); - })); - - it('should invalidate session', function () { - //GIVEN - $scope.series = "123456789"; - - //SET SPY - spyOn(SessionsService, 'delete'); - - //WHEN - $scope.invalidate($scope.series); - - //THEN - expect(SessionsService.delete).toHaveBeenCalled(); - expect(SessionsService.delete).toHaveBeenCalledWith({series: "123456789"}, jasmine.any(Function), jasmine.any(Function)); - - //SIMULATE SUCCESS CALLBACK CALL FROM SERVICE - SessionsService.delete.calls.mostRecent().args[1](); - expect($scope.error).toBeNull(); - expect($scope.success).toBe('OK'); - }); - }); -}); diff --git a/src/test/javascript/spec/app/account/settings/settingsControllerSpec.js b/src/test/javascript/spec/app/account/settings/settingsControllerSpec.js deleted file mode 100644 index 121857fe3..000000000 --- a/src/test/javascript/spec/app/account/settings/settingsControllerSpec.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict'; - -describe('Controllers Tests ', function () { - - beforeEach(module('jhipsterApp')); - - var $scope, q, Principal, Auth; - - // define the mock Auth service - beforeEach(function() { - Auth = { - updateAccount: function() {} - }; - - Principal = { - identity: function() { - var deferred = q.defer(); - return deferred.promise; - } - }; - }); - - - describe('SettingsController', function () { - - beforeEach(inject(function ($rootScope, $controller, $q) { - $scope = $rootScope.$new(); - q = $q; - $controller('SettingsController',{$scope:$scope, Principal:Principal, Auth:Auth}); - })); - - it('should save account', function () { - //GIVEN - var account = {firstName: "John", lastName: "Doe"}; - $scope.settingsAccount = account; - - //SET SPY - spyOn(Principal, 'identity').and.callThrough(); - - spyOn(Auth, 'updateAccount').and.returnValue(new function(){ - var deferred = q.defer(); - $scope.error = null; - $scope.success = 'OK'; - return deferred.promise; - }); - - - //WHEN - $scope.save(); - - //THEN - expect($scope.error).toBeNull(); - expect($scope.success).toBe('OK'); - }); - }); -}); diff --git a/src/test/javascript/spec/components/auth/auth.services.spec.js b/src/test/javascript/spec/components/auth/auth.services.spec.js index 7e5f27316..d818006ed 100644 --- a/src/test/javascript/spec/components/auth/auth.services.spec.js +++ b/src/test/javascript/spec/components/auth/auth.services.spec.js @@ -18,7 +18,6 @@ describe('Services Tests ', function () { $httpBackend.expectGET('scripts/components/navbar/navbar.html').respond({}); $httpBackend.expectGET('i18n/en/global.json').respond(200, ''); - $httpBackend.expectGET('i18n/en/language.json').respond(200, ''); $httpBackend.expectGET('i18n/en/main.json').respond(200, ''); $httpBackend.expectGET('scripts/app/main/main.html').respond({}); diff --git a/src/test/javascript/spec/components/auth/authServicesSpec.js b/src/test/javascript/spec/components/auth/authServicesSpec.js deleted file mode 100644 index 975419866..000000000 --- a/src/test/javascript/spec/components/auth/authServicesSpec.js +++ /dev/null @@ -1,49 +0,0 @@ -'use strict'; - -describe('Services Tests ', function () { - - beforeEach(module('jhipsterApp')); - - describe('Auth', function () { - var $httpBackend, spiedLocalStorageService, authService, spiedAuthServerProvider; - - beforeEach(inject(function($injector, localStorageService, Auth, AuthServerProvider) { - $httpBackend = $injector.get('$httpBackend'); - spiedLocalStorageService = localStorageService; - authService = Auth; - spiedAuthServerProvider = AuthServerProvider; - //Request on app init - $httpBackend.expectPOST(/api\/logout\?cacheBuster=\d+/).respond(200, ''); - - $httpBackend.expectGET('scripts/components/navbar/navbar.html').respond({}); - $httpBackend.expectGET('i18n/en/global.json').respond(200, ''); - $httpBackend.expectGET('i18n/en/language.json').respond(200, ''); - $httpBackend.expectGET('i18n/en/main.json').respond(200, ''); - $httpBackend.expectGET('scripts/app/main/main.html').respond({}); - $httpBackend.expectGET(/api\/account\?cacheBuster=\d+/).respond({}); - })); - //make sure no expectations were missed in your tests. - //(e.g. expectGET or expectPOST) - afterEach(function() { - $httpBackend.verifyNoOutstandingExpectation(); - $httpBackend.verifyNoOutstandingRequest(); - }); - - it('should call backend on logout then call authServerProvider.logout', function(){ - //GIVEN - //Set spy - spyOn(spiedAuthServerProvider, 'logout').and.callThrough(); - spyOn(spiedLocalStorageService, "clearAll").and.callThrough(); - - //WHEN - authService.logout(); - //flush the backend to "execute" the request to do the expectedGET assertion. - $httpBackend.flush(); - - //THEN - expect(spiedAuthServerProvider.logout).toHaveBeenCalled(); - expect(spiedLocalStorageService.clearAll).toHaveBeenCalled(); - }); - - }); -}); diff --git a/src/test/resources/config/application.yml b/src/test/resources/config/application.yml index 0104d3150..1521e6793 100644 --- a/src/test/resources/config/application.yml +++ b/src/test/resources/config/application.yml @@ -53,6 +53,7 @@ metrics: swagger: apiDocsLocation: http://localhost:8080 title: jhipster API + version: 0.0.1 description: jhipster applications and beyond! termsOfServiceUrl: http://jhipster.github.io/ contact: