Merge branch 'master' into Stabilise_tests

This commit is contained in:
asharani-murugesh
2016-03-11 15:59:10 +01:00
43 changed files with 735 additions and 458 deletions

View File

@@ -1,74 +1,95 @@
aopalliance:aopalliance:jar:1.0:compile
com.fasterxml.jackson.core:jackson-annotations:jar:2.5.0:compile
com.fasterxml.jackson.core:jackson-core:jar:2.5.0:compile
com.fasterxml.jackson.core:jackson-databind:jar:2.5.0:compile
com.fasterxml:classmate:jar:1.3.0:compile
com.google.guava:guava:jar:18.0:compile
com.h2database:h2:jar:1.4.186:compile
ch.qos.logback:logback-classic:jar:1.1.3:compile
ch.qos.logback:logback-core:jar:1.1.3:compile
com.fasterxml.jackson.core:jackson-annotations:jar:2.5.5:compile
com.fasterxml.jackson.core:jackson-core:jar:2.5.5:compile
com.fasterxml.jackson.core:jackson-databind:jar:2.5.5:compile
com.fasterxml:classmate:jar:1.1.0:compile
com.fasterxml:classmate:jar:1.2.0:compile
com.google.collections:google-collections:jar:1.0-rc2:compile
com.google.guava:guava:jar:19.0:compile
com.h2database:h2:jar:1.4.190:compile
com.jayway.jsonpath:json-path:jar:0.9.1:compile
com.netflix.feign:feign-core:jar:8.12.1:compile
com.netflix.feign:feign-core:jar:8.14.2:compile
com.netflix.feign:feign-jackson:jar:8.14.1:compile
com.netflix.feign:feign-ribbon:jar:8.1.1:compile
com.netflix.feign:feign-slf4j:jar:8.1.1:compile
com.netflix.ribbon:ribbon-core:jar:2.0.0:compile
com.netflix.ribbon:ribbon-httpclient:jar:2.0.0:compile
com.netflix.ribbon:ribbon-loadbalancer:jar:2.0.0:compile
com.netflix.ribbon:ribbon:jar:2.0.0:compile
com.rabbitmq:amqp-client:jar:3.5.5:compile
com.vaadin.external.atmosphere:atmosphere-runtime:jar:2.2.7.vaadin1:compile
com.vaadin.external.flute:flute:jar:1.3.0.gg2:compile
com.vaadin.external.google:guava:jar:16.0.1.vaadin1:compile
com.vaadin.external.slf4j:vaadin-slf4j-jdk14:jar:1.6.1:compile
com.vaadin.external.streamhtmlparser:streamhtmlparser-jsilver:jar:0.0.10.vaadin1:compile
com.vaadin:vaadin-push:jar:7.5.7:compile
com.vaadin:vaadin-sass-compiler:jar:0.9.12:compile
com.vaadin:vaadin-server:jar:7.5.7:compile
com.vaadin:vaadin-shared:jar:7.5.7:compile
com.vaadin:vaadin-client-compiled:jar:7.6.3:compile
com.vaadin:vaadin-push:jar:7.6.3:compile
com.vaadin:vaadin-sass-compiler:jar:0.9.13:compile
com.vaadin:vaadin-server:jar:7.6.3:compile
com.vaadin:vaadin-shared:jar:7.6.3:compile
com.vaadin:vaadin-spring-boot-starter:jar:1.0.0:compile
com.vaadin:vaadin-spring-boot:jar:1.0.0:compile
com.vaadin:vaadin-spring:jar:1.0.0:compile
com.vaadin:vaadin-themes:jar:7.5.7:compile
com.vaadin:vaadin-themes:jar:7.6.3:compile
com.yahoo.platform.yui:yuicompressor:jar:2.4.8:compile
commons-io:commons-io:jar:2.4:compile
cz.jirutka.rsql:rsql-parser:jar:2.0.0:compile
io.reactivex:rxjava:jar:1.0.11:compile
io.springfox:springfox-core:jar:2.0.3:compile
io.springfox:springfox-schema:jar:2.0.3:compile
io.springfox:springfox-spi:jar:2.0.3:compile
io.springfox:springfox-spring-web:jar:2.0.3:compile
io.springfox:springfox-swagger-common:jar:2.0.3:compile
io.springfox:springfox-swagger2:jar:2.0.3:compile
io.swagger:swagger-annotations:jar:1.5.0:compile
io.swagger:swagger-models:jar:1.5.0:compile
javax.servlet:javax.servlet-api:jar:3.1.0:compile
javax.transaction:javax.transaction-api:jar:1.2:compile
javax.validation:validation-api:jar:1.1.0.Final:compile
joda-time:joda-time:jar:2.5:compile
net._01001111:jlorem:jar:1.1:compile
net.minidev:json-smart:jar:1.2:compile
org.apache.commons:commons-lang3:jar:3.4:compile
org.apache.commons:commons-pool2:jar:2.2:compile
org.apache.logging.log4j:log4j-api:jar:2.1:compile
org.apache.logging.log4j:log4j-core:jar:2.1:compile
org.apache.logging.log4j:log4j-slf4j-impl:jar:2.1:compile
org.apache.tomcat:tomcat-jdbc:jar:8.0.28:compile
org.apache.tomcat:tomcat-juli:jar:8.0.28:compile
org.apache.tomcat:tomcat-jdbc:jar:8.0.30:compile
org.apache.tomcat:tomcat-juli:jar:8.0.30:compile
org.aspectj:aspectjrt:jar:1.8.5:compile
org.aspectj:aspectjweaver:jar:1.8.5:compile
org.eclipse.persistence:javax.persistence:jar:2.1.0:compile
org.eclipse.persistence:org.eclipse.persistence.antlr:jar:2.6.0:compile
org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.6.0:compile
org.eclipse.persistence:org.eclipse.persistence.core:jar:2.6.0:compile
org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:jar:2.6.0:compile
org.eclipse.persistence:org.eclipse.persistence.jpa:jar:2.6.0:compile
org.eclipse.persistence:javax.persistence:jar:2.1.1:compile
org.eclipse.persistence:org.eclipse.persistence.antlr:jar:2.6.2:compile
org.eclipse.persistence:org.eclipse.persistence.asm:jar:2.6.2:compile
org.eclipse.persistence:org.eclipse.persistence.core:jar:2.6.2:compile
org.eclipse.persistence:org.eclipse.persistence.jpa.jpql:jar:2.6.2:compile
org.eclipse.persistence:org.eclipse.persistence.jpa:jar:2.6.2:compile
org.flywaydb:flyway-core:jar:3.1:compile
org.glassfish:javax.json:jar:1.0.4:compile
org.hibernate:hibernate-validator:jar:5.2.2.Final:compile
org.hibernate:hibernate-validator:jar:5.2.4.Final:compile
org.jboss.logging:jboss-logging:jar:3.2.1.Final:compile
org.jsoup:jsoup:jar:1.8.1:compile
org.mapstruct:mapstruct:jar:1.0.0.Beta4:compile
org.mongodb:mongo-java-driver:jar:3.0.2:compile
org.json:json:jar:20141113:compile
org.jsoup:jsoup:jar:1.8.3:compile
org.mongodb:mongo-java-driver:jar:3.2.2:compile
org.objenesis:objenesis:jar:2.1:compile
org.slf4j:jcl-over-slf4j:jar:1.7.12:compile
org.slf4j:jul-to-slf4j:jar:1.7.12:compile
org.slf4j:slf4j-api:jar:1.7.7:compile
org.slf4j:jcl-over-slf4j:jar:1.7.13:compile
org.slf4j:jul-to-slf4j:jar:1.7.13:compile
org.slf4j:log4j-over-slf4j:jar:1.7.13:compile
org.slf4j:slf4j-api:jar:1.7.13:compile
org.springframework.amqp:spring-amqp:jar:1.4.6.RELEASE:compile
org.springframework.amqp:spring-rabbit:jar:1.4.6.RELEASE:compile
org.springframework.boot:spring-boot-autoconfigure:jar:1.2.7.RELEASE:compile
org.springframework.boot:spring-boot-starter-aop:jar:1.2.7.RELEASE:compile
org.springframework.boot:spring-boot-starter-data-jpa:jar:1.2.7.RELEASE:compile
org.springframework.boot:spring-boot-starter-jdbc:jar:1.2.7.RELEASE:compile
org.springframework.boot:spring-boot-starter-log4j2:jar:1.2.7.RELEASE:compile
org.springframework.boot:spring-boot-starter-web:jar:1.2.7.RELEASE:compile
org.springframework.boot:spring-boot-starter:jar:1.2.7.RELEASE:compile
org.springframework.boot:spring-boot:jar:1.2.7.RELEASE:compile
org.springframework.boot:spring-boot-autoconfigure:jar:1.2.8.RELEASE:compile
org.springframework.boot:spring-boot-configuration-processor:jar:1.2.8.RELEASE:compile
org.springframework.boot:spring-boot-starter-aop:jar:1.2.8.RELEASE:compile
org.springframework.boot:spring-boot-starter-data-jpa:jar:1.2.8.RELEASE:compile
org.springframework.boot:spring-boot-starter-jdbc:jar:1.2.8.RELEASE:compile
org.springframework.boot:spring-boot-starter-log4j2:jar:1.2.8.RELEASE:compile
org.springframework.boot:spring-boot-starter-logging:jar:1.2.8.RELEASE:compile
org.springframework.boot:spring-boot-starter-web:jar:1.2.8.RELEASE:compile
org.springframework.boot:spring-boot-starter:jar:1.2.8.RELEASE:compile
org.springframework.boot:spring-boot:jar:1.2.8.RELEASE:compile
org.springframework.cloud:spring-cloud-commons:jar:1.0.5.RELEASE:compile
org.springframework.cloud:spring-cloud-context:jar:1.0.5.RELEASE:compile
org.springframework.cloud:spring-cloud-netflix-core:jar:1.0.7.RELEASE:compile
org.springframework.cloud:spring-cloud-starter-feign:jar:1.0.6.RELEASE:compile
org.springframework.cloud:spring-cloud-starter-ribbon:jar:1.0.6.RELEASE:compile
org.springframework.cloud:spring-cloud-starter:jar:1.0.5.RELEASE:compile
org.springframework.data:spring-data-commons:jar:1.10.1.RELEASE:compile
org.springframework.data:spring-data-jpa:jar:1.8.1.RELEASE:compile
org.springframework.data:spring-data-mongodb:jar:1.7.1.RELEASE:compile
@@ -77,29 +98,33 @@
org.springframework.plugin:spring-plugin-core:jar:1.1.0.RELEASE:compile
org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
org.springframework.retry:spring-retry:jar:1.1.2.RELEASE:compile
org.springframework.security:spring-security-aspects:jar:3.2.8.RELEASE:compile
org.springframework.security:spring-security-config:jar:3.2.8.RELEASE:compile
org.springframework.security:spring-security-core:jar:3.2.8.RELEASE:compile
org.springframework.security:spring-security-web:jar:3.2.8.RELEASE:compile
org.springframework:spring-aop:jar:4.1.8.RELEASE:compile
org.springframework:spring-aspects:jar:4.1.8.RELEASE:compile
org.springframework:spring-beans:jar:4.1.8.RELEASE:compile
org.springframework:spring-context-support:jar:4.1.8.RELEASE:compile
org.springframework:spring-context:jar:4.1.8.RELEASE:compile
org.springframework:spring-core:jar:4.1.8.RELEASE:compile
org.springframework:spring-expression:jar:4.1.8.RELEASE:compile
org.springframework:spring-jdbc:jar:4.1.8.RELEASE:compile
org.springframework:spring-messaging:jar:4.1.8.RELEASE:compile
org.springframework:spring-orm:jar:4.1.8.RELEASE:compile
org.springframework:spring-tx:jar:4.1.8.RELEASE:compile
org.springframework:spring-web:jar:4.1.8.RELEASE:compile
org.springframework:spring-webmvc:jar:4.1.8.RELEASE:compile
org.springframework.security:spring-security-aspects:jar:3.2.9.RELEASE:compile
org.springframework.security:spring-security-config:jar:3.2.9.RELEASE:compile
org.springframework.security:spring-security-core:jar:3.2.9.RELEASE:compile
org.springframework.security:spring-security-crypto:jar:3.2.9.RELEASE:compile
org.springframework.security:spring-security-web:jar:3.2.9.RELEASE:compile
org.springframework:spring-aop:jar:4.1.9.RELEASE:compile
org.springframework:spring-aspects:jar:4.1.9.RELEASE:compile
org.springframework:spring-beans:jar:4.1.9.RELEASE:compile
org.springframework:spring-context-support:jar:4.1.9.RELEASE:compile
org.springframework:spring-context:jar:4.1.9.RELEASE:compile
org.springframework:spring-core:jar:4.1.9.RELEASE:compile
org.springframework:spring-expression:jar:4.1.9.RELEASE:compile
org.springframework:spring-jdbc:jar:4.1.9.RELEASE:compile
org.springframework:spring-messaging:jar:4.1.9.RELEASE:compile
org.springframework:spring-orm:jar:4.1.9.RELEASE:compile
org.springframework:spring-tx:jar:4.1.9.RELEASE:compile
org.springframework:spring-web:jar:4.1.9.RELEASE:compile
org.springframework:spring-webmvc:jar:4.1.9.RELEASE:compile
org.vaadin.addons.lazyquerycontainer:vaadin-lazyquerycontainer:jar:7.4.0.1:compile
org.vaadin.addons:contextmenu:jar:4.5:compile
org.vaadin.addons:flexibleoptiongroup:jar:2.2.0:compile
org.vaadin.addons:tokenfield:jar:7.0.1:compile
org.vaadin.alump.distributionbar:dbar-addon:jar:1.2.0:compile
org.vaadin.spring.addons:vaadin-spring-addon-eventbus:jar:0.0.6.RELEASE:compile
org.vaadin.spring.extensions:vaadin-spring-ext-core:jar:0.0.6.RELEASE:compile
org.vaadin.spring.extensions:vaadin-spring-ext-security:jar:0.0.6.RELEASE:compile
org.w3c.css:sac:jar:1.3:compile
org.yaml:snakeyaml:jar:1.14:compile
redis.clients:jedis:jar:2.5.2:compile
rhino:js:jar:1.7R2:compile

View File

@@ -6,3 +6,6 @@ find . -name dependencies.txt|while read i; do cat $i;done|grep '.*:.*:test'|sor
find . -name dependencies.txt|while read i; do cat $i;done|grep '.*:.*:provided'|sort|uniq > 3rd-dependencies/provided.txt
find . -name dependencies.txt|while read i; do rm $i;done
cd 3rd-dependencies/
cat compile.txt provided.txt|cut -d':' -f1-4|while read i; do grep -h $i test.txt;done|sort|uniq|while read x; do sed -i.bak -e s/$x// test.txt ;done
sed -i.bak '/^[[:space:]]*$/d' test.txt
rm *.bak

View File

@@ -1,6 +1,6 @@
javax.servlet:javax.servlet-api:jar:3.1.0:provided
org.apache.tomcat.embed:tomcat-embed-core:jar:8.0.28:provided
org.apache.tomcat.embed:tomcat-embed-el:jar:8.0.28:provided
org.apache.tomcat.embed:tomcat-embed-logging-juli:jar:8.0.28:provided
org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.0.28:provided
org.springframework.boot:spring-boot-starter-tomcat:jar:1.2.7.RELEASE:provided
org.apache.tomcat.embed:tomcat-embed-core:jar:8.0.30:provided
org.apache.tomcat.embed:tomcat-embed-el:jar:8.0.30:provided
org.apache.tomcat.embed:tomcat-embed-logging-juli:jar:8.0.30:provided
org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.0.30:provided
org.springframework.boot:spring-boot-starter-tomcat:jar:1.2.8.RELEASE:provided

View File

@@ -1,55 +1,36 @@
com.fasterxml.jackson.core:jackson-core:jar:2.5.0:test
com.fasterxml.jackson.core:jackson-databind:jar:2.5.0:test
com.github.fge:btf:jar:1.2:test
com.github.fge:jackson-coreutils:jar:1.6:test
com.github.fge:json-patch:jar:1.7:test
com.github.fge:msg-simple:jar:1.1:test
com.google.code.findbugs:jsr305:jar:2.0.1:test
com.h2database:h2:jar:1.4.186:test
com.jayway.jsonpath:json-path:jar:0.9.1:test
com.sun.jersey:jersey-client:jar:1.18.1:test
com.sun.jersey:jersey-core:jar:1.13:test
commons-beanutils:commons-beanutils-core:jar:1.8.3:test
commons-io:commons-io:jar:2.4:test
commons-logging:commons-logging:jar:1.1.1:test
de.flapdoodle.embed:de.flapdoodle.embed.mongo:jar:1.50.0:test
de.flapdoodle.embed:de.flapdoodle.embed.process:jar:1.50.0:test
io.swagger:swagger-annotations:jar:1.5.0:test
de.flapdoodle.embed:de.flapdoodle.embed.mongo:jar:1.50.2:test
de.flapdoodle.embed:de.flapdoodle.embed.process:jar:1.50.1:test
javax.el:javax.el-api:jar:2.2.4:test
junit:junit:jar:4.12:test
net.java.dev.jna:jna-platform:jar:4.0.0:test
net.java.dev.jna:jna:jar:3.3.0:test
net.java.dev.jna:jna:jar:4.0.0:test
net.java.dev.jna:jna:jar:platform:3.3.0:test
net.minidev:json-smart:jar:1.2:test
org.apache.commons:commons-compress:jar:1.3:test
org.apache.commons:commons-lang3:jar:3.1:test
org.apache.tika:tika-core:jar:1.7:test
org.aspectj:aspectjrt:jar:1.8.5:test
org.atteo:evo-inflector:jar:1.2.1:test
org.easytesting:fest-assert-core:jar:2.0M10:test
org.easytesting:fest-assert:jar:1.4:test
org.easytesting:fest-util:jar:1.2.5:test
org.hamcrest:hamcrest-core:jar:1.3:test
org.hamcrest:hamcrest-library:jar:1.3:test
org.json:json:jar:20141113:test
org.jvnet.jaxb2_commons:jaxb2-basics-runtime:jar:0.9.3:test
org.mariadb.jdbc:mariadb-java-client:jar:1.2.3:test
org.mariadb.jdbc:mariadb-java-client:jar:1.3.5:test
org.mockito:mockito-core:jar:1.10.19:test
org.objenesis:objenesis:jar:2.1:test
org.springframework.boot:spring-boot-starter-test:jar:1.2.7.RELEASE:test
org.springframework.boot:spring-boot-starter-test:jar:1.2.8.RELEASE:test
org.springframework.data:spring-data-rest-core:jar:2.3.1.RELEASE:test
org.springframework.data:spring-data-rest-webmvc:jar:2.3.1.RELEASE:test
org.springframework.hateoas:spring-hateoas:jar:0.16.0.RELEASE:test
org.springframework.plugin:spring-plugin-core:jar:1.1.0.RELEASE:test
org.springframework.security:spring-security-aspects:jar:3.2.8.RELEASE:test
org.springframework.security:spring-security-config:jar:3.2.8.RELEASE:test
org.springframework.security:spring-security-web:jar:3.2.8.RELEASE:test
org.springframework:spring-context-support:jar:4.1.8.RELEASE:test
org.springframework:spring-test:jar:4.1.8.RELEASE:test
org.springframework:spring-web:jar:4.1.8.RELEASE:test
org.springframework:spring-webmvc:jar:4.1.8.RELEASE:test
ru.yandex.qatools.allure:allure-java-adaptor-api:jar:1.4.15:test
ru.yandex.qatools.allure:allure-java-annotations:jar:1.4.15:test
ru.yandex.qatools.allure:allure-java-aspects:jar:1.4.15:test
ru.yandex.qatools.allure:allure-junit-adaptor:jar:1.4.15:test
ru.yandex.qatools.allure:allure-model:jar:1.4.15:test
org.springframework:spring-test:jar:4.1.9.RELEASE:test
ru.yandex.qatools.allure:allure-java-adaptor-api:jar:1.4.22:test
ru.yandex.qatools.allure:allure-java-annotations:jar:1.4.22:test
ru.yandex.qatools.allure:allure-java-aspects:jar:1.4.22:test
ru.yandex.qatools.allure:allure-junit-adaptor:jar:1.4.22:test
ru.yandex.qatools.allure:allure-model:jar:1.4.22:test
ru.yandex.qatools.properties:properties-loader:jar:1.5:test

View File

@@ -62,8 +62,9 @@ public class DeviceSimulatorUpdater {
device.setProgress(0.0);
device.setSwversion(swVersion);
eventbus.post(new InitUpdate(device));
threadPool.schedule(new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, callback),
2000, TimeUnit.MILLISECONDS);
2_000, TimeUnit.MILLISECONDS);
}
private static final class DeviceSimulatorUpdateThread implements Runnable {
@@ -91,7 +92,7 @@ public class DeviceSimulatorUpdater {
if (newProgress < 1.0) {
threadPool.schedule(
new DeviceSimulatorUpdateThread(device, spSenderService, actionId, eventbus, callback),
rndSleep.nextInt(3000), TimeUnit.MILLISECONDS);
rndSleep.nextInt(5_000), TimeUnit.MILLISECONDS);
} else {
callback.updateFinished(device, actionId);
}

View File

@@ -13,11 +13,8 @@ import java.util.Map;
import org.eclipse.hawkbit.dmf.amqp.api.EventTopic;
import org.eclipse.hawkbit.dmf.amqp.api.MessageHeaderKey;
import org.eclipse.hawkbit.dmf.amqp.api.MessageType;
import org.eclipse.hawkbit.dmf.json.model.ActionStatus;
import org.eclipse.hawkbit.dmf.json.model.DownloadAndUpdateRequest;
import org.eclipse.hawkbit.simulator.AbstractSimulatedDevice;
import org.eclipse.hawkbit.simulator.DeviceSimulatorUpdater;
import org.eclipse.hawkbit.simulator.DeviceSimulatorUpdater.UpdaterCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
@@ -139,31 +136,22 @@ public class SpReceiverService extends ReceiverService {
DownloadAndUpdateRequest.class);
final Long actionId = downloadAndUpdateRequest.getActionId();
try {
Thread.sleep(1_000);
} catch (final InterruptedException e) {
LOGGER.error("Sleep interrupted", e);
}
spSenderService.sendActionStatusMessage(tenant, ActionStatus.RUNNING,
"device Simulator retrieved update request. proceeding with simulation.", actionId);
deviceUpdater.startUpdate(tenant, thingId, actionId, downloadAndUpdateRequest.getSoftwareModules().get(0)
.getModuleVersion(), new UpdaterCallback() {
@Override
public void updateFinished(final AbstractSimulatedDevice device, final Long actionId) {
switch (device.getResponseStatus()) {
case SUCCESSFUL:
spSenderService.finishUpdateProcess(new SimulatedUpdate(device.getTenant(), device.getId(),
actionId), "Simulation complete!");
break;
case ERROR:
spSenderService.finishUpdateProcessWithError(new SimulatedUpdate(device.getTenant(),
device.getId(), actionId), "Simulation complete with error!");
break;
default:
break;
}
}
});
deviceUpdater.startUpdate(tenant, thingId, actionId,
downloadAndUpdateRequest.getSoftwareModules().get(0).getModuleVersion(), (device, actionId1) -> {
switch (device.getResponseStatus()) {
case SUCCESSFUL:
spSenderService.finishUpdateProcess(
new SimulatedUpdate(device.getTenant(), device.getId(), actionId1),
"Simulation complete!");
break;
case ERROR:
spSenderService.finishUpdateProcessWithError(
new SimulatedUpdate(device.getTenant(), device.getId(), actionId1),
"Simulation complete with error!");
break;
default:
break;
}
});
}
}

View File

@@ -9,14 +9,12 @@
package org.eclipse.hawkbit.mgmt.client;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* Configuration bean which holds the configuration of the client e.g. the base
* URL of the hawkbit-server and the credentials to use the RESTful Management
* API.
*/
@Component
@ConfigurationProperties(prefix = "hawkbit")
public class ClientConfigurationProperties {

View File

@@ -1,6 +1,3 @@
<!-- Copyright (c) 2015 Bosch Software Innovations GmbH and others. All rights reserved. This program and the accompanying
materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and
is available at http://www.eclipse.org/legal/epl-v10.html -->
<?xml version="1.0" encoding="UTF-8"?>
<!--

View File

@@ -20,7 +20,7 @@ import java.util.Map;
*/
public interface FieldNameProvider {
/**
* Seperator for the sub attributes
* Separator for the sub attributes
*/
public static final String SUB_ATTRIBUTE_SEPERATOR = ".";

View File

@@ -36,7 +36,7 @@ public enum SoftwareModuleTypeFields implements FieldNameProvider {
/**
* The max ds assignments field.
*/
MAX("maxAssignments");
MAXASSIGNMENTS("maxAssignments");
private final String fieldName;

View File

@@ -58,8 +58,8 @@ public class BaseAmqpService {
* @return the converted object
*/
@SuppressWarnings("unchecked")
protected <T> T convertMessage(final Message message, final Class<T> clazz) {
if (message == null) {
public <T> T convertMessage(final Message message, final Class<T> clazz) {
if (message == null || message.getBody() == null) {
return null;
}
message.getMessageProperties().getHeaders().put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME,
@@ -78,8 +78,8 @@ public class BaseAmqpService {
* @return the list of converted objects
*/
@SuppressWarnings("unchecked")
protected <T> List<T> convertMessageList(final Message message, final Class<T> clazz) {
if (message == null) {
public <T> List<T> convertMessageList(final Message message, final Class<T> clazz) {
if (message == null || message.getBody() == null) {
return Collections.emptyList();
}
message.getMessageProperties().getHeaders().put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME,
@@ -99,6 +99,7 @@ public class BaseAmqpService {
final Object value = header.get(key);
if (value == null) {
logAndThrowMessageError(message, errorMessageIfNull);
return null;
}
return value.toString();
}

View File

@@ -116,6 +116,7 @@ public class AmqpMessageHandlerServiceTest {
}
@Test
@Description("Tests not allowed content-type in message")
public void testWrongContentType() {
final MessageProperties messageProperties = new MessageProperties();

View File

@@ -0,0 +1,103 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.amqp;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.hawkbit.dmf.json.model.ActionUpdateStatus;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import ru.yandex.qatools.allure.annotations.Description;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Stories;
@RunWith(MockitoJUnitRunner.class)
@Features("Component Tests - Device Management Federation API")
@Stories("Base Amqp Service Test")
public class BaseAmqpServiceTest {
@Mock
private RabbitTemplate rabbitTemplate;
private BaseAmqpService baseAmqpService;
@Before
public void setup() {
when(rabbitTemplate.getMessageConverter()).thenReturn(new Jackson2JsonMessageConverter());
baseAmqpService = new BaseAmqpService(rabbitTemplate);
}
@Test
@Description("Verify that the message conversion works")
public void convertMessageTest() {
final ActionUpdateStatus actionUpdateStatus = new ActionUpdateStatus();
actionUpdateStatus.setActionId(1L);
actionUpdateStatus.setSoftwareModuleId(2L);
final Message message = rabbitTemplate.getMessageConverter().toMessage(actionUpdateStatus,
new MessageProperties());
ActionUpdateStatus convertedActionUpdateStatus = baseAmqpService.convertMessage(message,
ActionUpdateStatus.class);
assertThat(convertedActionUpdateStatus).as("Converted Action Status is wrong")
.isEqualsToByComparingFields(actionUpdateStatus);
convertedActionUpdateStatus = baseAmqpService.convertMessage(null, ActionUpdateStatus.class);
assertThat(convertedActionUpdateStatus).as("Converted Object should be null when message is null").isNull();
convertedActionUpdateStatus = baseAmqpService.convertMessage(new Message(null, new MessageProperties()),
ActionUpdateStatus.class);
assertThat(convertedActionUpdateStatus).as("Converted Object should be null when message body is null")
.isNull();
}
@Test
@Description("Verify that a conversion of a list from a message works")
public void convertMessageListTest() {
final List<ActionUpdateStatus> actionUpdateStatusList = new ArrayList<>();
for (int i = 0; i < 5; i++) {
final ActionUpdateStatus actionUpdateStatus = new ActionUpdateStatus();
actionUpdateStatus.setActionId(Long.valueOf(i));
actionUpdateStatus.setSoftwareModuleId(Long.valueOf(i));
actionUpdateStatusList.add(actionUpdateStatus);
}
final Message message = rabbitTemplate.getMessageConverter().toMessage(actionUpdateStatusList,
new MessageProperties());
List<ActionUpdateStatus> convertedActionUpdateStatus = baseAmqpService.convertMessageList(message,
ActionUpdateStatus.class);
assertThat(convertedActionUpdateStatus).as("Converted Action Status list is wrong")
.hasSameClassAs(actionUpdateStatusList);
assertThat(convertedActionUpdateStatus).as("Converted Action Status list is wrong")
.hasSameSizeAs(actionUpdateStatusList);
convertedActionUpdateStatus = baseAmqpService.convertMessageList(null, ActionUpdateStatus.class);
assertThat(convertedActionUpdateStatus).as("Converted list should be empty when message is null").isEmpty();
convertedActionUpdateStatus = baseAmqpService.convertMessageList(new Message(null, new MessageProperties()),
ActionUpdateStatus.class);
assertThat(convertedActionUpdateStatus).as("Converted list should be empty when message body is null")
.isEmpty();
}
}

View File

@@ -572,7 +572,7 @@ public class DeploymentManagement {
@Modifying
@Transactional
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
public Action forceQuitAction(@NotNull final Action action, @NotNull final Target target) {
public Action forceQuitAction(@NotNull final Action action) {
final Action mergedAction = entityManager.merge(action);
if (!mergedAction.isCancelingOrCanceled()) {

View File

@@ -69,7 +69,7 @@ import org.springframework.data.domain.Persistable;
@Index(name = "sp_idx_target_03", columnList = "tenant,controller_id,assigned_distribution_set"),
@Index(name = "sp_idx_target_04", columnList = "tenant,created_at"),
@Index(name = "sp_idx_target_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = {
"controller_id", "tenant" }, name = "uk_tenant_controller_id") )
"controller_id", "tenant" }, name = "uk_tenant_controller_id"))
@NamedEntityGraph(name = "Target.detail", attributeNodes = { @NamedAttributeNode("tags"),
@NamedAttributeNode(value = "assignedDistributionSet"), @NamedAttributeNode(value = "targetInfo") })
public class Target extends NamedEntity implements Persistable<Long> {
@@ -81,21 +81,21 @@ public class Target extends NamedEntity implements Persistable<Long> {
private String controllerId;
@Transient
private boolean isNew = false;
private boolean entityNew = false;
@ManyToMany(targetEntity = TargetTag.class)
@JoinTable(name = "sp_target_target_tag", joinColumns = {
@JoinColumn(name = "target", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_target") ) }, inverseJoinColumns = {
@JoinColumn(name = "tag", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_tag") ) })
@JoinColumn(name = "target", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_target")) }, inverseJoinColumns = {
@JoinColumn(name = "tag", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_targtag_tag")) })
private Set<TargetTag> tags = new HashSet<>();
@CascadeOnDelete
@OneToMany(fetch = FetchType.LAZY, orphanRemoval = true, cascade = { CascadeType.REMOVE })
@JoinColumn(name = "target", insertable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_act_hist_targ") )
@JoinColumn(name = "target", insertable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_act_hist_targ"))
private final List<Action> actions = new ArrayList<>();
@ManyToOne(optional = true, fetch = FetchType.LAZY, targetEntity = DistributionSet.class)
@JoinColumn(name = "assigned_distribution_set", nullable = true, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_assign_ds") )
@JoinColumn(name = "assigned_distribution_set", nullable = true, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_assign_ds"))
private DistributionSet assignedDistributionSet;
@CascadeOnDelete
@@ -217,15 +217,15 @@ public class Target extends NamedEntity implements Persistable<Long> {
@Override
@Transient
public boolean isNew() {
return isNew;
return entityNew;
}
/**
* @param isNew
* the isNew to set
*/
public void setNew(final boolean isNew) {
this.isNew = isNew;
public void setNew(final boolean entityNew) {
this.entityNew = entityNew;
}
/**

View File

@@ -73,11 +73,11 @@ public class TargetInfo implements Persistable<Long>, Serializable {
private Long targetId;
@Transient
private boolean isNew = false;
private boolean entityNew = false;
@CascadeOnDelete
@OneToOne(cascade = { CascadeType.MERGE, CascadeType.REMOVE }, fetch = FetchType.LAZY, targetEntity = Target.class)
@JoinColumn(name = "target_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_stat_targ") )
@JoinColumn(name = "target_id", nullable = false, updatable = false, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_stat_targ"))
@MapsId
// use deprecated annotation until HHH-8862 is fixed
// @SuppressWarnings( "deprecation" )
@@ -98,7 +98,7 @@ public class TargetInfo implements Persistable<Long>, Serializable {
private TargetUpdateStatus updateStatus = TargetUpdateStatus.UNKNOWN;
@ManyToOne(optional = true, fetch = FetchType.LAZY)
@JoinColumn(name = "installed_distribution_set", nullable = true, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_inst_ds") )
@JoinColumn(name = "installed_distribution_set", nullable = true, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_target_inst_ds"))
private DistributionSet installedDistributionSet;
/**
@@ -108,7 +108,7 @@ public class TargetInfo implements Persistable<Long>, Serializable {
@Column(name = "attribute_value", length = 128)
@MapKeyColumn(name = "attribute_key", nullable = false, length = 32)
@CollectionTable(name = "sp_target_attributes", joinColumns = {
@JoinColumn(name = "target_id") }, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_attrib_target") )
@JoinColumn(name = "target_id") }, foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_targ_attrib_target"))
// use deprecated annotation until HHH-8862 is fixed
@SuppressWarnings("deprecation")
// @org.hibernate.annotations.ForeignKey( name = "fk_targ_attrib_target" )
@@ -154,15 +154,15 @@ public class TargetInfo implements Persistable<Long>, Serializable {
@Override
@Transient
public boolean isNew() {
return isNew;
return entityNew;
}
/**
* @param isNew
* the isNew to set
*/
public void setNew(final boolean isNew) {
this.isNew = isNew;
public void setNew(final boolean entityNew) {
this.entityNew = entityNew;
}
/**

View File

@@ -11,7 +11,6 @@ package org.eclipse.hawkbit;
import static org.fest.assertions.api.Assertions.assertThat;
import java.util.List;
import java.util.Properties;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@@ -31,6 +30,7 @@ import org.eclipse.hawkbit.repository.LocalArtifactRepository;
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
import org.eclipse.hawkbit.repository.RolloutGroupRepository;
import org.eclipse.hawkbit.repository.RolloutManagement;
import org.eclipse.hawkbit.repository.RolloutRepository;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SoftwareModuleMetadataRepository;
import org.eclipse.hawkbit.repository.SoftwareModuleRepository;
@@ -190,6 +190,9 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware {
@Autowired
protected RolloutGroupRepository rolloutGroupRepository;
@Autowired
protected RolloutRepository rolloutRepository;
protected MockMvc mvc;
@Autowired
@@ -208,23 +211,6 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware {
private static CIMySqlTestDatabase tesdatabase;
static {
final Properties props = System.getProperties();
// if( props.getProperty( SuiteEmbeddedConfiguration.IM_HOME ) == null )
// {
// props.setProperty( SuiteEmbeddedConfiguration.IM_HOME,
// "./src/test/resources/im" );
// }
}
/*
* (non-Javadoc)
*
* @see org.springframework.context.EnvironmentAware#setEnvironment(org.
* springframework.core.env. Environment)
*/
@Override
public void setEnvironment(final Environment environment) {
this.environment = environment;
@@ -287,6 +273,8 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware {
assertThat(softwareModuleTypeRepository.findAll()).isEmpty();
assertThat(distributionSetTypeRepository.findAll()).isEmpty();
assertThat(tenantMetaDataRepository.findAll()).isEmpty();
assertThat(rolloutGroupRepository.findAll()).isEmpty();
assertThat(rolloutRepository.findAll()).isEmpty();
}
@Transactional

View File

@@ -10,7 +10,6 @@ package org.eclipse.hawkbit.repository;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import java.util.ArrayList;
@@ -50,7 +49,6 @@ import com.google.common.eventbus.Subscribe;
import ru.yandex.qatools.allure.annotations.Description;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Issue;
import ru.yandex.qatools.allure.annotations.Stories;
/**
@@ -313,7 +311,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
deploymentManagement.cancelAction(assigningAction, target);
assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId());
deploymentManagement.forceQuitAction(assigningAction, target);
deploymentManagement.forceQuitAction(assigningAction);
assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId());
@@ -351,8 +349,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
// force quit assignment
try {
deploymentManagement.forceQuitAction(assigningAction,
targetManagement.findTargetByControllerID(target.getControllerId()));
deploymentManagement.forceQuitAction(assigningAction);
fail("expected ForceQuitActionNotAllowedException");
} catch (final ForceQuitActionNotAllowedException ex) {
}
@@ -765,13 +762,16 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
distributionSetManagement.findDistributionSetByIdWithDetails(dsA.getId()).getOptLockRevision());
// verifying that the assignment is correct
assertEquals("Active target actions are wrong", 1, deploymentManagement.findActiveActionsByTarget(targ).size());
assertEquals("Target actions are wrong", 1, deploymentManagement.findActionsByTarget(targ).size());
assertEquals("Target status is wrong", TargetUpdateStatus.PENDING, targ.getTargetInfo().getUpdateStatus());
assertEquals("Assigned ds is wrong", dsA, targ.getAssignedDistributionSet());
assertEquals("Active ds is wrong", dsA,
deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet());
assertNull("Installed ds should be null", targ.getTargetInfo().getInstalledDistributionSet());
assertThat(deploymentManagement.findActiveActionsByTarget(targ).size()).as("Active target actions are wrong")
.isEqualTo(1);
assertThat(deploymentManagement.findActionsByTarget(targ).size()).as("Target actions are wrong").isEqualTo(1);
assertThat(targ.getTargetInfo().getUpdateStatus()).as("UpdateStatus of target is wrong")
.isEqualTo(TargetUpdateStatus.PENDING);
assertThat(targ.getAssignedDistributionSet()).as("Assigned distribution set of target is wrong").isEqualTo(dsA);
assertThat(deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet())
.as("Distribution set of actionn is wrong").isEqualTo(dsA);
assertThat(deploymentManagement.findActiveActionsByTarget(targ).get(0).getDistributionSet())
.as("Installed distribution set of action should be null").isNotNull();
final Page<Action> updAct = actionRepository.findByDistributionSet(pageReq, dsA);
final Action action = updAct.getContent().get(0);
@@ -781,12 +781,13 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
targ = targetManagement.findTargetByControllerID(targ.getControllerId());
assertEquals(0, deploymentManagement.findActiveActionsByTarget(targ).size());
assertEquals(1, deploymentManagement.findInActiveActionsByTarget(targ).size());
assertEquals("active target actions are wrong", 0, deploymentManagement.findActiveActionsByTarget(targ).size());
assertEquals("active actions are wrong", 1, deploymentManagement.findInActiveActionsByTarget(targ).size());
assertEquals(TargetUpdateStatus.IN_SYNC, targ.getTargetInfo().getUpdateStatus());
assertEquals(dsA, targ.getAssignedDistributionSet());
assertEquals(dsA, targ.getTargetInfo().getInstalledDistributionSet());
assertEquals("tagret update status is not correct", TargetUpdateStatus.IN_SYNC,
targ.getTargetInfo().getUpdateStatus());
assertEquals("wrong assigned ds", dsA, targ.getAssignedDistributionSet());
assertEquals("wrong installed ds", dsA, targ.getTargetInfo().getInstalledDistributionSet());
targs = deploymentManagement.assignDistributionSet(dsB.getId(), new String[] { "target-id-A" })
.getAssignedTargets();
@@ -796,7 +797,7 @@ public class DeploymentManagementTest extends AbstractIntegrationTest {
assertEquals("active actions are wrong", 1, deploymentManagement.findActiveActionsByTarget(targ).size());
assertEquals("target status is wrong", TargetUpdateStatus.PENDING,
targetManagement.findTargetByControllerID(targ.getControllerId()).getTargetInfo().getUpdateStatus());
assertEquals(dsB, targ.getAssignedDistributionSet());
assertEquals("wrong assigned ds", dsB, targ.getAssignedDistributionSet());
assertEquals("Installed ds is wrong", dsA.getId(),
targetManagement.findTargetByControllerIDWithDetails(targ.getControllerId()).getTargetInfo()
.getInstalledDistributionSet().getId());

View File

@@ -14,6 +14,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import org.eclipse.hawkbit.AbstractIntegrationTest;
import org.eclipse.hawkbit.TestDataUtil;
@@ -34,6 +35,8 @@ import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.repository.rsql.RSQLUtility;
import org.eclipse.hawkbit.repository.utils.MultipleInvokeHelper;
import org.eclipse.hawkbit.repository.utils.SuccessCondition;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Description;
@@ -859,7 +862,7 @@ public class RolloutManagementTest extends AbstractIntegrationTest {
@Test
@Description("Verify the creation and the start of a rollout in asynchronous mode.")
public void createAndStartRolloutInAsync() {
public void createAndStartRolloutInAsync() throws Exception {
final int amountTargetsForRollout = 500;
final int amountGroups = 5;
@@ -883,31 +886,18 @@ public class RolloutManagementTest extends AbstractIntegrationTest {
myRollout = rolloutManagement.createRolloutAsync(myRollout, amountGroups, conditions);
int counter = 1;
int counterMax = 10;
while (!isRolloutInGivenStatus(myRollout.getId(), RolloutStatus.READY) && (counter <= counterMax)) {
try {
Thread.sleep(500);
} catch (final InterruptedException e) {
e.printStackTrace();
}
counter++;
}
SuccessConditionRolloutStatus conditionRolloutTargetCount = new SuccessConditionRolloutStatus(
RolloutStatus.READY);
assertThat(MultipleInvokeHelper.doWithTimeout(new RolloutStatusCallable(myRollout.getId()),
conditionRolloutTargetCount, 15000, 500)).as("Rollout status").isNotNull();
myRollout = rolloutManagement.findRolloutById(myRollout.getId());
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.READY);
rolloutManagement.startRolloutAsync(myRollout);
counter = 1;
counterMax = 10;
while (!isRolloutInGivenStatus(myRollout.getId(), RolloutStatus.RUNNING) && counter <= counterMax) {
try {
Thread.sleep(500);
} catch (final InterruptedException e) {
e.printStackTrace();
}
counter++;
}
conditionRolloutTargetCount = new SuccessConditionRolloutStatus(RolloutStatus.RUNNING);
assertThat(MultipleInvokeHelper.doWithTimeout(new RolloutStatusCallable(myRollout.getId()),
conditionRolloutTargetCount, 15000, 500)).as("Rollout status").isNotNull();
myRollout = rolloutManagement.findRolloutById(myRollout.getId());
assertThat(myRollout.getStatus()).isEqualTo(RolloutStatus.RUNNING);
@@ -917,14 +907,6 @@ public class RolloutManagementTest extends AbstractIntegrationTest {
validateRolloutActionStatus(myRollout.getId(), expectedTargetCountStatus);
}
private boolean isRolloutInGivenStatus(final Long rolloutID, final RolloutStatus status) {
final Rollout myRollout = rolloutManagement.findRolloutById(rolloutID);
if (myRollout.getStatus() == status) {
return true;
}
return false;
}
private void validateRolloutGroupActionStatus(final RolloutGroup rolloutGroup,
final Map<TotalTargetCountStatus.Status, Long> expectedTargetCountStatus) {
final RolloutGroup rolloutGroupWithDetail = rolloutGroupManagement
@@ -1021,4 +1003,35 @@ public class RolloutManagementTest extends AbstractIntegrationTest {
return map;
}
private static class SuccessConditionRolloutStatus implements SuccessCondition<RolloutStatus> {
private final RolloutStatus rolloutStatus;
public SuccessConditionRolloutStatus(final RolloutStatus rolloutStatus) {
this.rolloutStatus = rolloutStatus;
}
@Override
public boolean success(final RolloutStatus result) {
return result.equals(rolloutStatus);
}
}
private class RolloutStatusCallable implements Callable<RolloutStatus> {
final Long rolloutId;
RolloutStatusCallable(final Long rolloutId) {
this.rolloutId = rolloutId;
}
@Override
public RolloutStatus call() throws Exception {
final Rollout myRollout = rolloutManagement.findRolloutById(rolloutId);
return myRollout.getStatus();
}
}
}

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.repository;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.List;
@@ -22,6 +23,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.Tag;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetTag;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.LoggerFactory;
@@ -42,6 +44,11 @@ public class TagManagementTest extends AbstractIntegrationTest {
LOG = LoggerFactory.getLogger(TagManagementTest.class);
}
@Before
public void setup() {
assertThat(targetTagRepository.findAll()).as("Not tags should be available").isEmpty();
}
@Test
@Description("Full DS tag lifecycle tested. Create tags, assign them to sets and delete the tags.")
public void createAndAssignAndDeleteDistributionSetTags() {
@@ -88,7 +95,7 @@ public class TagManagementTest extends AbstractIntegrationTest {
// search for not deleted
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
.setTagNames(Lists.newArrayList(tagA.getName()));
assertEquals(
assertEquals("filter works not correct",
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
@@ -96,7 +103,7 @@ public class TagManagementTest extends AbstractIntegrationTest {
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
.setTagNames(Lists.newArrayList(tagB.getName()));
assertEquals(
assertEquals("filter works not correct",
dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
@@ -104,7 +111,7 @@ public class TagManagementTest extends AbstractIntegrationTest {
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
.setTagNames(Lists.newArrayList(tagC.getName()));
assertEquals(
assertEquals("filter works not correct",
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
@@ -112,22 +119,22 @@ public class TagManagementTest extends AbstractIntegrationTest {
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true)
.setTagNames(Lists.newArrayList(tagX.getName()));
assertEquals(0, distributionSetManagement
assertEquals("filter works not correct", 0, distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements());
assertEquals(5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
assertEquals("wrong tag size", 5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
tagManagement.deleteDistributionSetTag(tagY.getName());
assertEquals(4, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
assertEquals("wrong tag size", 4, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
tagManagement.deleteDistributionSetTag(tagX.getName());
assertEquals(3, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
assertEquals("wrong tag size", 3, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
tagManagement.deleteDistributionSetTag(tagB.getName());
assertEquals(2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
assertEquals("wrong tag size", 2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown());
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
.setTagNames(Lists.newArrayList(tagA.getName()));
assertEquals(
assertEquals("filter works not correct",
dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown()
+ dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
@@ -135,12 +142,12 @@ public class TagManagementTest extends AbstractIntegrationTest {
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
.setTagNames(Lists.newArrayList(tagB.getName()));
assertEquals(0, distributionSetManagement
assertEquals("filter works not correct", 0, distributionSetManagement
.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements());
distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE)
.setTagNames(Lists.newArrayList(tagC.getName()));
assertEquals(
assertEquals("filter works not correct",
dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown()
+ dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(),
distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build())
@@ -154,30 +161,25 @@ public class TagManagementTest extends AbstractIntegrationTest {
@Test
@Description("Ensures that all tags are retrieved through repository.")
public void findAllTargetTags() {
assertThat(targetTagRepository.findAll()).isEmpty();
final List<TargetTag> tags = createTargetsWithTags();
assertThat(targetTagRepository.findAll()).isEqualTo(tagManagement.findAllTargetTags()).isEqualTo(tags)
.hasSize(20);
.as("Wrong tag size").hasSize(20);
}
@Test
@Description("Ensures that a created tag is persisted in the repository as defined.")
public void createTargetTag() {
assertThat(targetTagRepository.findAll()).isEmpty();
final Tag tag = tagManagement.createTargetTag(new TargetTag("kai1", "kai2", "colour"));
assertThat(targetTagRepository.findByNameEquals("kai1").getDescription()).isEqualTo("kai2");
assertThat(tagManagement.findTargetTag("kai1").getColour()).isEqualTo("colour");
assertThat(tagManagement.findTargetTagById(tag.getId()).getColour()).isEqualTo("colour");
assertThat(targetTagRepository.findByNameEquals("kai1").getDescription()).as("wrong tag ed").isEqualTo("kai2");
assertThat(tagManagement.findTargetTag("kai1").getColour()).as("wrong tag found").isEqualTo("colour");
assertThat(tagManagement.findTargetTagById(tag.getId()).getColour()).as("wrong tag found").isEqualTo("colour");
}
@Test
@Description("Ensures that a deleted tag is removed from the repository as defined.")
public void deleteTargetTas() {
assertThat(targetTagRepository.findAll()).isEmpty();
// create test data
final Iterable<TargetTag> tags = createTargetsWithTags();
@@ -196,16 +198,13 @@ public class TagManagementTest extends AbstractIntegrationTest {
assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getTags())
.doesNotContain(toDelete);
}
assertThat(targetTagRepository.findOne(toDelete.getId())).isNull();
assertThat(tagManagement.findAllTargetTags()).hasSize(19);
assertThat(targetTagRepository.findOne(toDelete.getId())).as("No tag should be found").isNull();
assertThat(tagManagement.findAllTargetTags()).as("Wrong target tag size").hasSize(19);
}
@Test
@Description("Tests the name update of a target tag.")
public void updateTargetTag() {
assertThat(targetTagRepository.findAll()).isEmpty();
// create test data
final List<TargetTag> tags = createTargetsWithTags();
// change data
@@ -216,95 +215,104 @@ public class TagManagementTest extends AbstractIntegrationTest {
tagManagement.updateTargetTag(savedAssigned);
// check data
assertThat(tagManagement.findAllTargetTags()).hasSize(tags.size());
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getName()).isEqualTo("test123");
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getOptLockRevision()).isEqualTo(2);
assertThat(tagManagement.findAllTargetTags()).as("Wrong target tag size").hasSize(tags.size());
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getName()).as("wrong target tag is saved")
.isEqualTo("test123");
assertThat(targetTagRepository.findOne(savedAssigned.getId()).getOptLockRevision())
.as("wrong target tag is saved").isEqualTo(2);
}
@Test
@Description("Ensures that a created tag is persisted in the repository as defined.")
public void createDistributionSetTag() {
assertThat(distributionSetTagRepository.findAll()).isEmpty();
final Tag tag = tagManagement.createDistributionSetTag(new DistributionSetTag("kai1", "kai2", "colour"));
assertThat(distributionSetTagRepository.findByNameEquals("kai1").getDescription()).isEqualTo("kai2");
assertThat(tagManagement.findDistributionSetTag("kai1").getColour()).isEqualTo("colour");
assertThat(tagManagement.findDistributionSetTagById(tag.getId()).getColour()).isEqualTo("colour");
assertThat(distributionSetTagRepository.findByNameEquals("kai1").getDescription()).as("wrong tag found")
.isEqualTo("kai2");
assertThat(tagManagement.findDistributionSetTag("kai1").getColour()).as("wrong tag found").isEqualTo("colour");
assertThat(tagManagement.findDistributionSetTagById(tag.getId()).getColour()).as("wrong tag found")
.isEqualTo("colour");
}
@Test
@Description("Ensures that a created tags are persisted in the repository as defined.")
public void createDistributionSetTags() {
assertThat(distributionSetTagRepository.findAll()).isEmpty();
final List<DistributionSetTag> tags = createDsSetsWithTags();
assertThat(distributionSetTagRepository.findAll()).hasSize(tags.size());
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags created").hasSize(tags.size());
}
@Test
@Description("Ensures that a deleted tag is removed from the repository as defined.")
public void deleteDistributionSetTag() {
assertThat(distributionSetTagRepository.findAll()).isEmpty();
// create test data
final Iterable<DistributionSetTag> tags = createDsSetsWithTags();
final DistributionSetTag toDelete = tags.iterator().next();
for (final DistributionSet set : distributionSetRepository.findAll()) {
assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags())
.contains(toDelete);
.as("Wrong tag found").contains(toDelete);
}
// delete
tagManagement.deleteDistributionSetTag(tags.iterator().next().getName());
// check
assertThat(distributionSetTagRepository.findOne(toDelete.getId())).isNull();
assertThat(tagManagement.findAllDistributionSetTags()).hasSize(19);
assertThat(distributionSetTagRepository.findOne(toDelete.getId())).as("Deleted tag should be null").isNull();
assertThat(tagManagement.findAllDistributionSetTags()).as("Wrong size of tags after deletion").hasSize(19);
for (final DistributionSet set : distributionSetRepository.findAll()) {
assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags())
.doesNotContain(toDelete);
.as("Wrong found tags").doesNotContain(toDelete);
}
}
@Test(expected = EntityAlreadyExistsException.class)
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
public void failedDuplicateTargetTagNameException() {
tagManagement.createTargetTag(new TargetTag("A"));
tagManagement.createTargetTag(new TargetTag("A"));
try {
tagManagement.createTargetTag(new TargetTag("A"));
fail("Expected EntityAlreadyExistsException");
} catch (final EntityAlreadyExistsException e) {
}
}
@Test(expected = EntityAlreadyExistsException.class)
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
public void failedDuplicateTargetTagNameExceptionAfterUpdate() {
tagManagement.createTargetTag(new TargetTag("A"));
final TargetTag tag = tagManagement.createTargetTag(new TargetTag("B"));
tag.setName("A");
tagManagement.updateTargetTag(tag);
try {
tagManagement.updateTargetTag(tag);
fail("Expected EntityAlreadyExistsException");
} catch (final EntityAlreadyExistsException e) {
}
}
@Test(expected = EntityAlreadyExistsException.class)
@Description("Ensures that a tag cannot be created if one exists already with that name (ecpects EntityAlreadyExistsException).")
public void failedDuplicateDsTagNameException() {
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
try {
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
fail("Expected EntityAlreadyExistsException");
} catch (final EntityAlreadyExistsException e) {
}
}
@Test(expected = EntityAlreadyExistsException.class)
@Description("Ensures that a tag cannot be updated to a name that already exists on another tag (ecpects EntityAlreadyExistsException).")
public void failedDuplicateDsTagNameExceptionAfterUpdate() {
tagManagement.createDistributionSetTag(new DistributionSetTag("A"));
final DistributionSetTag tag = tagManagement.createDistributionSetTag(new DistributionSetTag("B"));
tag.setName("A");
tagManagement.updateDistributionSetTag(tag);
try {
tagManagement.updateDistributionSetTag(tag);
fail("Expected EntityAlreadyExistsException");
} catch (final EntityAlreadyExistsException e) {
}
}
@Test
@Description("Tests the name update of a target tag.")
public void updateDistributionSetTag() {
assertThat(distributionSetTagRepository.findAll()).isEmpty();
// create test data
final List<DistributionSetTag> tags = createDsSetsWithTags();
@@ -317,20 +325,19 @@ public class TagManagementTest extends AbstractIntegrationTest {
tagManagement.updateDistributionSetTag(savedAssigned);
// check data
assertThat(tagManagement.findAllDistributionSetTags()).hasSize(tags.size());
assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).isEqualTo("test123");
assertThat(tagManagement.findAllDistributionSetTags()).as("Wrong size of ds tags").hasSize(tags.size());
assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).as("Wrong ds tag found")
.isEqualTo("test123");
}
@Test
@Description("Ensures that all tags are retrieved through repository.")
public void findDistributionSetTagsAll() {
assertThat(distributionSetTagRepository.findAll()).isEmpty();
final List<DistributionSetTag> tags = createDsSetsWithTags();
// test
assertThat(tagManagement.findAllDistributionSetTags()).hasSize(tags.size());
assertThat(distributionSetTagRepository.findAll()).hasSize(20);
assertThat(tagManagement.findAllDistributionSetTags()).as("Wrong size of tags").hasSize(tags.size());
assertThat(distributionSetTagRepository.findAll()).as("Wrong size of tags").hasSize(20);
}
private List<TargetTag> createTargetsWithTags() {

View File

@@ -98,7 +98,7 @@ public class RSQLDistributionSetFieldTest extends AbstractIntegrationTest {
assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "==true", 4);
try {
assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "==noExist*", 0);
fail();
fail("Expected RSQLParameterSyntaxException");
} catch (final RSQLParameterSyntaxException e) {
}
assertRSQLQuery(DistributionSetFields.COMPLETE.name() + "=in=(true)", 4);

View File

@@ -55,7 +55,7 @@ public class RSQLSoftwareModuleTypeFieldsTest extends AbstractIntegrationTest {
@Test
@Description("Test filter software module test type by max")
public void testFilterByMaxAssignment() {
assertRSQLQuery(SoftwareModuleTypeFields.MAX.name() + "==1", 3);
assertRSQLQuery(SoftwareModuleTypeFields.MAXASSIGNMENTS.name() + "==1", 3);
}
private void assertRSQLQuery(final String rsqlParam, final long excpectedEntity) {

View File

@@ -0,0 +1,94 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository.utils;
import java.util.concurrent.Callable;
/**
* Helper to call a request multiple times regarding a given condition until
* timeout is reached.
*
*/
public final class MultipleInvokeHelper {
/**
* Call with timeout until result is not null.
*
* @param callable
* class
* @param timeout
* value
* @param pollInterval
* value
* @return
* @throws Exception
*/
public static <T> T doWithTimeoutUntilResultIsNotNull(final Callable<T> callable, final long timeout,
final long pollInterval) throws Exception // NOPMD
{
return doWithTimeout(callable, new SuccessCondition<T>() {
@Override
public boolean success(final T result) {
return result != null;
};
}, timeout, pollInterval);
}
/**
* Call with timeout.
*
* @param callable
* class
* @param successCondition
* class
* @param timeout
* value
* @param pollInterval
* value
* @return
* @throws Exception
*/
public static <T> T doWithTimeout(final Callable<T> callable, final SuccessCondition<T> successCondition,
final long timeout, final long pollInterval) throws Exception // NOPMD
{
if (pollInterval < 0) {
throw new IllegalArgumentException("pollInterval must non negative");
}
long duration = 0;
Exception exception = null;
T returnValue = null;
while (untilTimeoutReached(timeout, duration)) {
try {
returnValue = callable.call();
// clear exception
exception = null;
} catch (final Exception ex) {
exception = ex;
}
Thread.sleep(pollInterval);
duration += pollInterval > 0 ? pollInterval : 1;
if (exception == null && successCondition.success(returnValue)) {
return returnValue;
} else {
returnValue = null;
}
}
if (exception != null) {
throw exception;
}
return returnValue;
}
private static boolean untilTimeoutReached(final long timeout, final long duration) {
return duration <= timeout || timeout < 0;
}
}

View File

@@ -0,0 +1,27 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository.utils;
/**
* SuccessCondition Interface.
*
* @param <T>
* type of the value to get verified
*/
public interface SuccessCondition<T> {
/**
* The implementation of the success condition.
*
* @param result
* @return
*/
boolean success(final T result);
}

View File

@@ -64,7 +64,7 @@ public class DistributionSetTypeResource implements DistributionSetTypeRestApi {
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
final Sort sorting = PagingUtility.sanitizeSoftwareModuleSortParam(sortParam);
final Sort sorting = PagingUtility.sanitizeDistributionSetTypeSortParam(sortParam);
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);

View File

@@ -12,10 +12,12 @@ import org.eclipse.hawkbit.repository.ActionFields;
import org.eclipse.hawkbit.repository.ActionStatusFields;
import org.eclipse.hawkbit.repository.DistributionSetFields;
import org.eclipse.hawkbit.repository.DistributionSetMetadataFields;
import org.eclipse.hawkbit.repository.DistributionSetTypeFields;
import org.eclipse.hawkbit.repository.RolloutFields;
import org.eclipse.hawkbit.repository.RolloutGroupFields;
import org.eclipse.hawkbit.repository.SoftwareModuleFields;
import org.eclipse.hawkbit.repository.SoftwareModuleMetadataFields;
import org.eclipse.hawkbit.repository.SoftwareModuleTypeFields;
import org.eclipse.hawkbit.repository.TargetFields;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
@@ -48,103 +50,92 @@ public final class PagingUtility {
}
static Sort sanitizeTargetSortParam(final String sortParam) {
final Sort sorting;
if (sortParam != null) {
sorting = new Sort(SortUtility.parse(TargetFields.class, sortParam));
} else {
// default sort
sorting = new Sort(Direction.ASC, TargetFields.NAME.getFieldName());
if (sortParam == null) {
// default
return new Sort(Direction.ASC, TargetFields.NAME.getFieldName());
}
return sorting;
return new Sort(SortUtility.parse(TargetFields.class, sortParam));
}
static Sort sanitizeSoftwareModuleSortParam(final String sortParam) {
final Sort sorting;
if (sortParam != null) {
sorting = new Sort(SortUtility.parse(SoftwareModuleFields.class, sortParam));
} else {
// default sort
sorting = new Sort(Direction.ASC, SoftwareModuleFields.NAME.getFieldName());
if (sortParam == null) {
// default
return new Sort(Direction.ASC, SoftwareModuleFields.NAME.getFieldName());
}
return sorting;
return new Sort(SortUtility.parse(SoftwareModuleFields.class, sortParam));
}
static Sort sanitizeSoftwareModuleTypeSortParam(final String sortParam) {
if (sortParam == null) {
// default
return new Sort(Direction.ASC, SoftwareModuleTypeFields.NAME.getFieldName());
}
return new Sort(SortUtility.parse(SoftwareModuleTypeFields.class, sortParam));
}
static Sort sanitizeDistributionSetSortParam(final String sortParam) {
final Sort sorting;
if (sortParam != null) {
sorting = new Sort(SortUtility.parse(DistributionSetFields.class, sortParam));
} else {
// default sort
sorting = new Sort(Direction.ASC, DistributionSetFields.NAME.getFieldName());
if (sortParam == null) {
// default
return new Sort(Direction.ASC, DistributionSetFields.NAME.getFieldName());
}
return sorting;
return new Sort(SortUtility.parse(DistributionSetFields.class, sortParam));
}
static Sort sanitizeDistributionSetTypeSortParam(final String sortParam) {
if (sortParam == null) {
// default
return new Sort(Direction.ASC, DistributionSetTypeFields.NAME.getFieldName());
}
return new Sort(SortUtility.parse(DistributionSetTypeFields.class, sortParam));
}
static Sort sanitizeActionSortParam(final String sortParam) {
final Sort sorting;
if (sortParam != null) {
sorting = new Sort(SortUtility.parse(ActionFields.class, sortParam));
} else {
if (sortParam == null) {
// default sort is DESC in case of action to match behavior
// of management UI (last entry on top)
sorting = new Sort(Direction.DESC, ActionFields.ID.getFieldName());
return new Sort(Direction.DESC, ActionFields.ID.getFieldName());
}
return sorting;
return new Sort(SortUtility.parse(ActionFields.class, sortParam));
}
static Sort sanitizeActionStatusSortParam(final String sortParam) {
final Sort sorting;
if (sortParam != null) {
sorting = new Sort(SortUtility.parse(ActionStatusFields.class, sortParam));
} else {
if (sortParam == null) {
// default sort is DESC in case of action status to match behavior
// of management UI (last entry on top)
sorting = new Sort(Direction.DESC, ActionStatusFields.ID.getFieldName());
return new Sort(Direction.DESC, ActionStatusFields.ID.getFieldName());
}
return sorting;
return new Sort(SortUtility.parse(ActionStatusFields.class, sortParam));
}
static Sort sanitizeDistributionSetMetadataSortParam(final String sortParam) {
final Sort sorting;
if (sortParam != null) {
sorting = new Sort(SortUtility.parse(DistributionSetMetadataFields.class, sortParam));
} else {
// default sort
sorting = new Sort(Direction.ASC, DistributionSetMetadataFields.KEY.getFieldName());
if (sortParam == null) {
// default
return new Sort(Direction.ASC, DistributionSetMetadataFields.KEY.getFieldName());
}
return sorting;
return new Sort(SortUtility.parse(DistributionSetMetadataFields.class, sortParam));
}
static Sort sanitizeSoftwareModuleMetadataSortParam(final String sortParam) {
final Sort sorting;
if (sortParam != null) {
sorting = new Sort(SortUtility.parse(SoftwareModuleMetadataFields.class, sortParam));
} else {
// default sort
sorting = new Sort(Direction.ASC, SoftwareModuleMetadataFields.KEY.getFieldName());
if (sortParam == null) {
// default
return new Sort(Direction.ASC, SoftwareModuleMetadataFields.KEY.getFieldName());
}
return sorting;
return new Sort(SortUtility.parse(SoftwareModuleMetadataFields.class, sortParam));
}
static Sort sanitizeRolloutSortParam(final String sortParam) {
final Sort sorting;
if (sortParam != null) {
sorting = new Sort(SortUtility.parse(RolloutFields.class, sortParam));
} else {
// default sort
sorting = new Sort(Direction.ASC, RolloutFields.NAME.getFieldName());
if (sortParam == null) {
// default
return new Sort(Direction.ASC, RolloutFields.NAME.getFieldName());
}
return sorting;
return new Sort(SortUtility.parse(RolloutFields.class, sortParam));
}
static Sort sanitizeRolloutGroupSortParam(final String sortParam) {
final Sort sorting;
if (sortParam != null) {
sorting = new Sort(SortUtility.parse(RolloutGroupFields.class, sortParam));
} else {
// default sort
sorting = new Sort(Direction.ASC, RolloutGroupFields.NAME.getFieldName());
if (sortParam == null) {
// default
return new Sort(Direction.ASC, RolloutGroupFields.NAME.getFieldName());
}
return sorting;
return new Sort(SortUtility.parse(RolloutGroupFields.class, sortParam));
}
}

View File

@@ -48,7 +48,7 @@ public class SoftwareModuleTypeResource implements SoftwareModuleTypeRestApi {
final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam);
final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam);
final Sort sorting = PagingUtility.sanitizeSoftwareModuleSortParam(sortParam);
final Sort sorting = PagingUtility.sanitizeSoftwareModuleTypeSortParam(sortParam);
final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting);

View File

@@ -209,7 +209,7 @@ public class TargetResource implements TargetRestApi {
final Action action = findActionWithExceptionIfNotFound(actionId);
if (force) {
this.deploymentManagement.forceQuitAction(action, target);
this.deploymentManagement.forceQuitAction(action);
} else {
this.deploymentManagement.cancelAction(action, target);
}

View File

@@ -89,6 +89,43 @@ public class DistributionSetTypeResourceTest extends AbstractIntegrationTest {
.andExpect(jsonPath("$total", equalTo(4)));
}
@Test
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes GET requests with sorting by KEY.")
public void getDistributionSetTypesSortedByKey() throws Exception {
DistributionSetType testType = distributionSetManagement
.createDistributionSetType(new DistributionSetType("zzzzz", "TestName123", "Desc123"));
testType.setDescription("Desc1234");
testType = distributionSetManagement.updateDistributionSetType(testType);
// descending
mvc.perform(get("/rest/v1/distributionsettypes").accept(MediaType.APPLICATION_JSON)
.param(RestConstants.REQUEST_PARAMETER_SORTING, "KEY:DESC")).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$content.[0].id", equalTo(testType.getId().intValue())))
.andExpect(jsonPath("$content.[0].name", equalTo("TestName123")))
.andExpect(jsonPath("$content.[0].description", equalTo("Desc1234")))
.andExpect(jsonPath("$content.[0].createdBy", equalTo("uploadTester")))
.andExpect(jsonPath("$content.[0].createdAt", equalTo(testType.getCreatedAt())))
.andExpect(jsonPath("$content.[0].lastModifiedBy", equalTo("uploadTester")))
.andExpect(jsonPath("$content.[0].lastModifiedAt", equalTo(testType.getLastModifiedAt())))
.andExpect(jsonPath("$content.[0].key", equalTo("zzzzz"))).andExpect(jsonPath("$total", equalTo(4)));
// ascending
mvc.perform(get("/rest/v1/distributionsettypes").accept(MediaType.APPLICATION_JSON)
.param(RestConstants.REQUEST_PARAMETER_SORTING, "KEY:ASC")).andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$content.[3].id", equalTo(testType.getId().intValue())))
.andExpect(jsonPath("$content.[3].name", equalTo("TestName123")))
.andExpect(jsonPath("$content.[3].description", equalTo("Desc1234")))
.andExpect(jsonPath("$content.[3].createdBy", equalTo("uploadTester")))
.andExpect(jsonPath("$content.[3].createdAt", equalTo(testType.getCreatedAt())))
.andExpect(jsonPath("$content.[3].lastModifiedBy", equalTo("uploadTester")))
.andExpect(jsonPath("$content.[3].lastModifiedAt", equalTo(testType.getLastModifiedAt())))
.andExpect(jsonPath("$content.[3].key", equalTo("zzzzz"))).andExpect(jsonPath("$total", equalTo(4)));
}
@Test
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/distributionsettypes POST requests.")

View File

@@ -453,8 +453,8 @@ public class RolloutResourceTest extends AbstractIntegrationTest {
.andExpect(status().isOk());
// check if running
assertThat(doWithTimeout(() -> getRollout(rollout.getId()), result -> success(result), 5000, 100)).isNotNull();
assertThat(doWithTimeout(() -> getRollout(rollout.getId()), result -> success(result), 60_000, 100))
.isNotNull();
}
@Test

View File

@@ -311,7 +311,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo
.andExpect(header().string("ETag", artifact.getSha1Hash()))
.andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)).andReturn();
assertTrue(Arrays.equals(result.getResponse().getContentAsByteArray(), random));
assertTrue("Wrong response content", Arrays.equals(result.getResponse().getContentAsByteArray(), random));
final MvcResult result2 = mvc
.perform(get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", sm.getId(),

View File

@@ -90,6 +90,46 @@ public class SoftwareModuleTypeResourceTest extends AbstractIntegrationTest {
.andExpect(jsonPath("$total", equalTo(4)));
}
@Test
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes GET requests with sorting by MAXASSIGNMENTS field.")
public void getSoftwareModuleTypesSortedByMaxAssignments() throws Exception {
SoftwareModuleType testType = softwareManagement
.createSoftwareModuleType(new SoftwareModuleType("test123", "TestName123", "Desc123", 5));
testType.setDescription("Desc1234");
testType = softwareManagement.updateSoftwareModuleType(testType);
// descending
mvc.perform(get("/rest/v1/softwaremoduletypes").accept(MediaType.APPLICATION_JSON)
.param(RestConstants.REQUEST_PARAMETER_SORTING, "MAXASSIGNMENTS:DESC"))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$content.[0].id", equalTo(testType.getId().intValue())))
.andExpect(jsonPath("$content.[0].name", equalTo("TestName123")))
.andExpect(jsonPath("$content.[0].description", equalTo("Desc1234")))
.andExpect(jsonPath("$content.[0].createdBy", equalTo("uploadTester")))
.andExpect(jsonPath("$content.[0].createdAt", equalTo(testType.getCreatedAt())))
.andExpect(jsonPath("$content.[0].lastModifiedBy", equalTo("uploadTester")))
.andExpect(jsonPath("$content.[0].lastModifiedAt", equalTo(testType.getLastModifiedAt())))
.andExpect(jsonPath("$content.[0].maxAssignments", equalTo(5)))
.andExpect(jsonPath("$content.[0].key", equalTo("test123"))).andExpect(jsonPath("$total", equalTo(4)));
// ascending
mvc.perform(get("/rest/v1/softwaremoduletypes").accept(MediaType.APPLICATION_JSON)
.param(RestConstants.REQUEST_PARAMETER_SORTING, "MAXASSIGNMENTS:ASC"))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$content.[3].id", equalTo(testType.getId().intValue())))
.andExpect(jsonPath("$content.[3].name", equalTo("TestName123")))
.andExpect(jsonPath("$content.[3].description", equalTo("Desc1234")))
.andExpect(jsonPath("$content.[3].createdBy", equalTo("uploadTester")))
.andExpect(jsonPath("$content.[3].createdAt", equalTo(testType.getCreatedAt())))
.andExpect(jsonPath("$content.[3].lastModifiedBy", equalTo("uploadTester")))
.andExpect(jsonPath("$content.[3].lastModifiedAt", equalTo(testType.getLastModifiedAt())))
.andExpect(jsonPath("$content.[3].maxAssignments", equalTo(5)))
.andExpect(jsonPath("$content.[3].key", equalTo("test123"))).andExpect(jsonPath("$total", equalTo(4)));
}
@Test
@WithUser(principal = "uploadTester", allSpPermissions = true)
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes POST requests.")

View File

@@ -61,7 +61,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
private static final String EMPTY_VIEW = "";
private EventPushStrategy pushStrategy;
private transient EventPushStrategy pushStrategy;
@Autowired
private SpringViewProvider viewProvider;

View File

@@ -438,17 +438,17 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
if (permChecker.hasUpdateDistributionPermission()) {
optionValues.add(updateType.getValue());
}
createOptionGroup(optionValues);
createOptionGroupByValues(optionValues);
}
private void singleMultiOptionGroup() {
final List<String> optionValues = new ArrayList<>();
optionValues.add(singleAssign.getValue());
optionValues.add(multiAssign.getValue());
assignOptionGroup(optionValues);
assignOptionGroupByValues(optionValues);
}
private void createOptionGroup(final List<String> tagOptions) {
private void createOptionGroupByValues(final List<String> tagOptions) {
createOptiongroup = new OptionGroup("", tagOptions);
createOptiongroup.setStyleName(ValoTheme.OPTIONGROUP_SMALL);
createOptiongroup.addStyleName("custom-option-group");
@@ -458,7 +458,7 @@ public class CreateUpdateSoftwareTypeLayout extends CustomComponent implements C
}
}
private void assignOptionGroup(final List<String> tagOptions) {
private void assignOptionGroupByValues(final List<String> tagOptions) {
assignOptiongroup = new OptionGroup("", tagOptions);
assignOptiongroup.setStyleName(ValoTheme.OPTIONGROUP_SMALL);
assignOptiongroup.addStyleName("custom-option-group");

View File

@@ -50,9 +50,9 @@ public class ArtifactUploadState implements Serializable {
private boolean swTypeFilterClosed = Boolean.FALSE;
private boolean isSwModuleTableMaximized = Boolean.FALSE;
private boolean swModuleTableMaximized = Boolean.FALSE;
private boolean isArtifactDetailsMaximized = Boolean.FALSE;
private boolean artifactDetailsMaximized = Boolean.FALSE;
private final Set<String> selectedDeleteSWModuleTypes = new HashSet<>();
@@ -152,15 +152,15 @@ public class ArtifactUploadState implements Serializable {
* @return the isSwModuleTableMaximized
*/
public boolean isSwModuleTableMaximized() {
return isSwModuleTableMaximized;
return swModuleTableMaximized;
}
/**
* @param isSwModuleTableMaximized
* the isSwModuleTableMaximized to set
*/
public void setSwModuleTableMaximized(final boolean isSwModuleTableMaximized) {
this.isSwModuleTableMaximized = isSwModuleTableMaximized;
public void setSwModuleTableMaximized(final boolean swModuleTableMaximized) {
this.swModuleTableMaximized = swModuleTableMaximized;
}
public Set<String> getSelectedDeleteSWModuleTypes() {
@@ -171,15 +171,15 @@ public class ArtifactUploadState implements Serializable {
* @return the isArtifactDetailsMaximized
*/
public boolean isArtifactDetailsMaximized() {
return isArtifactDetailsMaximized;
return artifactDetailsMaximized;
}
/**
* @param isArtifactDetailsMaximized
* the isArtifactDetailsMaximized to set
*/
public void setArtifactDetailsMaximized(final boolean isArtifactDetailsMaximized) {
this.isArtifactDetailsMaximized = isArtifactDetailsMaximized;
public void setArtifactDetailsMaximized(final boolean artifactDetailsMaximized) {
this.artifactDetailsMaximized = artifactDetailsMaximized;
}
/**

View File

@@ -38,11 +38,9 @@ public class ProxyTarget extends Target {
private TargetIdName targetIdName;
private Long createdAt;
private String assignedDistNameVersion;
private String assignedDistNameVersion = null;
private String installedDistNameVersion = null;
private String installedDistNameVersion;
private String pollStatusToolTip;
@@ -251,22 +249,6 @@ public class ProxyTarget extends Target {
this.installedDistributionSet = installedDistributionSet;
}
/**
* @return the createdAt
*/
@Override
public Long getCreatedAt() {
return createdAt;
}
/**
* @param createdAt
* the createdAt to set
*/
public void setCreatedAt(final Long createdAt) {
this.createdAt = createdAt;
}
/**
* @return the targetIdName
*/

View File

@@ -555,10 +555,10 @@ public class CreateUpdateDistSetTypeLayout extends CustomComponent implements Co
if (permChecker.hasUpdateDistributionPermission()) {
optionValues.add(updateDistType.getValue());
}
createOptionGroup(optionValues);
createOptionGroupByValues(optionValues);
}
private void createOptionGroup(final List<String> typeOptions) {
private void createOptionGroupByValues(final List<String> typeOptions) {
createOptiongroup = new OptionGroup("", typeOptions);
createOptiongroup.setId(SPUIDefinitions.CREATE_OPTION_GROUP_DISTRIBUTION_SET_TYPE_ID);
createOptiongroup.addStyleName(ValoTheme.OPTIONGROUP_SMALL);

View File

@@ -62,9 +62,9 @@ public class ManageDistUIState implements Serializable {
private final Map<Long, String> deleteSofwareModulesList = new HashMap<>();
private boolean isSwModuleTableMaximized = Boolean.FALSE;
private boolean swModuleTableMaximized = Boolean.FALSE;
private boolean isDsTableMaximized = Boolean.FALSE;
private boolean dsTableMaximized = Boolean.FALSE;
private final Map<String, SoftwareModuleIdName> assignedSoftwareModuleDetails = new HashMap<>();
@@ -219,7 +219,7 @@ public class ManageDistUIState implements Serializable {
* @return boolean
*/
public boolean isDsTableMaximized() {
return isDsTableMaximized;
return dsTableMaximized;
}
/***
@@ -227,8 +227,8 @@ public class ManageDistUIState implements Serializable {
*
* @param isDsModuleTableMaximized
*/
public void setDsTableMaximized(final boolean isDsModuleTableMaximized) {
isDsTableMaximized = isDsModuleTableMaximized;
public void setDsTableMaximized(final boolean dsModuleTableMaximized) {
dsTableMaximized = dsModuleTableMaximized;
}
public Map<String, SoftwareModuleIdName> getAssignedSoftwareModuleDetails() {
@@ -239,15 +239,15 @@ public class ManageDistUIState implements Serializable {
* @return the isSwModuleTableMaximized
*/
public boolean isSwModuleTableMaximized() {
return isSwModuleTableMaximized;
return swModuleTableMaximized;
}
/**
* @param isSwModuleTableMaximized
* the isSwModuleTableMaximized to set
*/
public void setSwModuleTableMaximized(final boolean isSwModuleTableMaximized) {
this.isSwModuleTableMaximized = isSwModuleTableMaximized;
public void setSwModuleTableMaximized(final boolean swModuleTableMaximized) {
this.swModuleTableMaximized = swModuleTableMaximized;
}
/**

View File

@@ -844,7 +844,7 @@ public class ActionHistoryTable extends TreeTable implements Handler {
if (actionId != null) {
final Action activeAction = deploymentManagement.findAction(actionId);
try {
deploymentManagement.forceQuitAction(activeAction, target);
deploymentManagement.forceQuitAction(activeAction);
return true;
} catch (final CancelActionNotAllowedException e) {
LOG.info("Force Cancel action not allowed exception :{}", e);

View File

@@ -94,8 +94,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
@Autowired
private transient TenantMetaDataRepository tenantMetaDataRepository;
private Button saveDistribution;
private Button discardDistribution;
private Button saveDistributionBtn;
private Button discardDistributionBtn;
private TextField distNameTextField;
private TextField distVersionTextField;
private Label madatoryLabel;
@@ -103,7 +103,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
private CheckBox reqMigStepCheckbox;
private ComboBox distsetTypeNameComboBox;
private boolean editDistribution = Boolean.FALSE;
private Long editDistId = null;
private Long editDistId;
private Window addDistributionWindow;
private String originalDistName;
private String originalDistVersion;
@@ -131,9 +131,9 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
final HorizontalLayout buttonsLayout = new HorizontalLayout();
buttonsLayout.setSizeFull();
buttonsLayout.setStyleName("dist-buttons-horz-layout");
buttonsLayout.addComponents(saveDistribution, discardDistribution);
buttonsLayout.setComponentAlignment(saveDistribution, Alignment.BOTTOM_LEFT);
buttonsLayout.setComponentAlignment(discardDistribution, Alignment.BOTTOM_RIGHT);
buttonsLayout.addComponents(saveDistributionBtn, discardDistributionBtn);
buttonsLayout.setComponentAlignment(saveDistributionBtn, Alignment.BOTTOM_LEFT);
buttonsLayout.setComponentAlignment(discardDistributionBtn, Alignment.BOTTOM_RIGHT);
buttonsLayout.addStyleName("window-style");
/*
@@ -186,14 +186,14 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
reqMigStepCheckbox.setId(SPUIComponetIdProvider.DIST_ADD_MIGRATION_CHECK);
/* save or update button */
saveDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_SAVE, "", "", "", true,
saveDistributionBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_SAVE, "", "", "", true,
FontAwesome.SAVE, SPUIButtonStyleSmallNoBorder.class);
saveDistribution.addClickListener(event -> saveDistribution());
saveDistributionBtn.addClickListener(event -> saveDistribution());
/* close button */
discardDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "", true,
FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
discardDistribution.addClickListener(event -> discardDistribution());
discardDistributionBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "",
true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class);
discardDistributionBtn.addClickListener(event -> discardDistribution());
}
/**
@@ -216,7 +216,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
}
private void enableSaveButton() {
saveDistribution.setEnabled(true);
saveDistributionBtn.setEnabled(true);
}
private DistributionSetType getDefaultDistributionSetType() {
@@ -226,7 +226,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
}
private void disableSaveButton() {
saveDistribution.setEnabled(false);
saveDistributionBtn.setEnabled(false);
}
private void saveDistribution() {
@@ -415,7 +415,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
distsetTypeNameComboBox.removeStyleName(SPUIStyleDefinitions.SP_COMBOFIELD_ERROR);
descTextArea.clear();
reqMigStepCheckbox.clear();
saveDistribution.setEnabled(true);
saveDistributionBtn.setEnabled(true);
removeListeners();
changedComponents.clear();
}
@@ -497,7 +497,7 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout {
public void populateValuesOfDistribution(final Long editDistId) {
this.editDistId = editDistId;
editDistribution = Boolean.TRUE;
saveDistribution.setEnabled(false);
saveDistributionBtn.setEnabled(false);
final DistributionSet distSet = distributionSetManagement.findDistributionSetByIdWithDetails(editDistId);
if (distSet != null) {
distNameTextField.setValue(distSet.getName());

View File

@@ -62,20 +62,20 @@ public class ManagementUIState implements Serializable {
private boolean distTagFilterClosed = true;
private Long targetsTruncated = null;
private Long targetsTruncated;
private final AtomicLong targetsCountAll = new AtomicLong();
private boolean isDsTableMaximized = Boolean.FALSE;
private boolean dsTableMaximized = Boolean.FALSE;
// Contains ID and NAme of last selected target
private DistributionSetIdName lastSelectedDsIdName;
// Contains list of ID and Names of all the selected Targets
private Set<DistributionSetIdName> selectedDsIdName = Collections.emptySet();
private boolean isTargetTableMaximized = Boolean.FALSE;
private boolean targetTableMaximized = Boolean.FALSE;
private boolean isActionHistoryMaximized = Boolean.FALSE;
private boolean actionHistoryMaximized = Boolean.FALSE;
private boolean noDataAvilableTarget = Boolean.FALSE;
@@ -255,11 +255,11 @@ public class ManagementUIState implements Serializable {
}
public boolean isDsTableMaximized() {
return isDsTableMaximized;
return dsTableMaximized;
}
public void setDsTableMaximized(final boolean isDsTableMaximized) {
this.isDsTableMaximized = isDsTableMaximized;
this.dsTableMaximized = isDsTableMaximized;
}
public DistributionSetIdName getLastSelectedDsIdName() {
@@ -282,7 +282,7 @@ public class ManagementUIState implements Serializable {
* @return the isTargetTableMaximized
*/
public boolean isTargetTableMaximized() {
return isTargetTableMaximized;
return targetTableMaximized;
}
/**
@@ -290,14 +290,14 @@ public class ManagementUIState implements Serializable {
* the isTargetTableMaximized to set
*/
public void setTargetTableMaximized(final boolean isTargetTableMaximized) {
this.isTargetTableMaximized = isTargetTableMaximized;
this.targetTableMaximized = isTargetTableMaximized;
}
/**
* @return the isActionHistoryMaximized
*/
public boolean isActionHistoryMaximized() {
return isActionHistoryMaximized;
return actionHistoryMaximized;
}
/**
@@ -305,7 +305,7 @@ public class ManagementUIState implements Serializable {
* the isActionHistoryMaximized to set
*/
public void setActionHistoryMaximized(final boolean isActionHistoryMaximized) {
this.isActionHistoryMaximized = isActionHistoryMaximized;
this.actionHistoryMaximized = isActionHistoryMaximized;
}
/**

View File

@@ -128,9 +128,9 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
private TextArea description;
private Button saveRollout;
private Button saveRolloutBtn;
private Button discardRolllout;
private Button discardRollloutBtn;
private OptionGroup errorThresholdOptionGroup;
@@ -138,7 +138,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
private Window addUpdateRolloutWindow;
private Boolean editRollout;
private Boolean editRolloutEnabled;
private Rollout rolloutForEdit;
@@ -167,7 +167,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
* Reset the field values.
*/
public void resetComponents() {
editRollout = Boolean.FALSE;
editRolloutEnabled = Boolean.FALSE;
rolloutName.clear();
targetFilterQuery.clear();
resetFields();
@@ -212,7 +212,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
final HorizontalLayout groupLayout = new HorizontalLayout();
groupLayout.setSizeFull();
groupLayout.addComponents(noOfGroups, groupSizeLabel);
groupLayout.setExpandRatio(noOfGroups, 1.0f);
groupLayout.setExpandRatio(noOfGroups, 1.0F);
groupLayout.setComponentAlignment(groupSizeLabel, Alignment.MIDDLE_LEFT);
return groupLayout;
}
@@ -221,7 +221,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
final HorizontalLayout errorThresoldLayout = new HorizontalLayout();
errorThresoldLayout.setSizeFull();
errorThresoldLayout.addComponents(errorThreshold, errorThresholdOptionGroup);
errorThresoldLayout.setExpandRatio(errorThreshold, 1.0f);
errorThresoldLayout.setExpandRatio(errorThreshold, 1.0F);
return errorThresoldLayout;
}
@@ -229,9 +229,9 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
final HorizontalLayout targetFilterLayout = new HorizontalLayout();
targetFilterLayout.setSizeFull();
targetFilterLayout.addComponents(targetFilterQueryCombo, targetFilterQuery, totalTargetsLabel);
targetFilterLayout.setExpandRatio(targetFilterQueryCombo, 0.71f);
targetFilterLayout.setExpandRatio(targetFilterQuery, 0.70f);
targetFilterLayout.setExpandRatio(totalTargetsLabel, 0.29f);
targetFilterLayout.setExpandRatio(targetFilterQueryCombo, 0.71F);
targetFilterLayout.setExpandRatio(targetFilterQuery, 0.70F);
targetFilterLayout.setExpandRatio(totalTargetsLabel, 0.29F);
targetFilterLayout.setComponentAlignment(totalTargetsLabel, Alignment.MIDDLE_LEFT);
return targetFilterLayout;
}
@@ -240,7 +240,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
final HorizontalLayout triggerThresholdLayout = new HorizontalLayout();
triggerThresholdLayout.setSizeFull();
triggerThresholdLayout.addComponents(triggerThreshold, getPercentHintLabel());
triggerThresholdLayout.setExpandRatio(triggerThreshold, 1.0f);
triggerThresholdLayout.setExpandRatio(triggerThreshold, 1.0F);
return triggerThresholdLayout;
}
@@ -254,9 +254,9 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
private HorizontalLayout getSaveDiscardButtonLayout() {
final HorizontalLayout buttonsLayout = new HorizontalLayout();
buttonsLayout.setSizeFull();
buttonsLayout.addComponents(saveRollout, discardRolllout);
buttonsLayout.setComponentAlignment(saveRollout, Alignment.BOTTOM_LEFT);
buttonsLayout.setComponentAlignment(discardRolllout, Alignment.BOTTOM_RIGHT);
buttonsLayout.addComponents(saveRolloutBtn, discardRollloutBtn);
buttonsLayout.setComponentAlignment(saveRolloutBtn, Alignment.BOTTOM_LEFT);
buttonsLayout.setComponentAlignment(discardRollloutBtn, Alignment.BOTTOM_RIGHT);
buttonsLayout.addStyleName("window-style");
return buttonsLayout;
}
@@ -277,8 +277,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
description = createDescription();
errorThresholdOptionGroup = createErrorThresholdOptionGroup();
setDefaultSaveStartGroupOption();
saveRollout = createSaveButton();
discardRolllout = createDiscardButton();
saveRolloutBtn = createSaveButton();
discardRollloutBtn = createDiscardButton();
actionTypeOptionGroupLayout.selectDefaultOption();
totalTargetsLabel = createTotalTargetsLabel();
@@ -383,8 +383,9 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
private Container createTargetFilterComboContainer() {
final BeanQueryFactory<TargetFilterBeanQuery> targetFilterQF = new BeanQueryFactory<>(
TargetFilterBeanQuery.class);
return new LazyQueryContainer(new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE,
SPUILabelDefinitions.VAR_NAME), targetFilterQF);
return new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_NAME),
targetFilterQF);
}
@@ -410,7 +411,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
}
private void onRolloutSave() {
if (editRollout) {
if (editRolloutEnabled) {
editRollout();
} else {
createRollout();
@@ -422,8 +423,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
rolloutForEdit.setName(rolloutName.getValue());
rolloutForEdit.setDescription(description.getValue());
final DistributionSetIdName distributionSetIdName = (DistributionSetIdName) distributionSet.getValue();
rolloutForEdit.setDistributionSet(distributionSetManagement.findDistributionSetById(distributionSetIdName
.getId()));
rolloutForEdit.setDistributionSet(
distributionSetManagement.findDistributionSetById(distributionSetIdName.getId()));
rolloutForEdit.setActionType(getActionType());
rolloutForEdit.setForcedTime(getForcedTimeStamp());
final int amountGroup = Integer.parseInt(noOfGroups.getValue());
@@ -453,8 +454,9 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
private long getForcedTimeStamp() {
return (((ActionTypeOptionGroupLayout.ActionTypeOption) actionTypeOptionGroupLayout.getActionTypeOptionGroup()
.getValue()) == ActionTypeOption.AUTO_FORCED) ? actionTypeOptionGroupLayout.getForcedTimeDateField()
.getValue().getTime() : Action.NO_FORCE_TIME;
.getValue()) == ActionTypeOption.AUTO_FORCED)
? actionTypeOptionGroupLayout.getForcedTimeDateField().getValue().getTime()
: Action.NO_FORCE_TIME;
}
private ActionType getActionType() {
@@ -487,8 +489,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
rolloutToCreate.setName(rolloutName.getValue());
rolloutToCreate.setDescription(description.getValue());
rolloutToCreate.setTargetFilterQuery(targetFilter);
rolloutToCreate.setDistributionSet(distributionSetManagement.findDistributionSetById(distributionSetIdName
.getId()));
rolloutToCreate
.setDistributionSet(distributionSetManagement.findDistributionSetById(distributionSetIdName.getId()));
rolloutToCreate.setActionType(getActionType());
rolloutToCreate.setForcedTime(getForcedTimeStamp());
@@ -499,8 +501,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
private String getTargetFilterQuery() {
if (null != targetFilterQueryCombo.getValue()
&& HawkbitCommonUtil.trimAndNullIfEmpty((String) targetFilterQueryCombo.getValue()) != null) {
final Item filterItem = targetFilterQueryCombo.getContainerDataSource().getItem(
targetFilterQueryCombo.getValue());
final Item filterItem = targetFilterQueryCombo.getContainerDataSource()
.getItem(targetFilterQueryCombo.getValue());
return (String) filterItem.getItemProperty("query").getValue();
}
return null;
@@ -568,8 +570,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
private boolean duplicateCheck() {
if (rolloutManagement.findRolloutByName(getRolloutName()) != null) {
uiNotification.displayValidationError(i18n.get("message.rollout.duplicate.check",
new Object[] { getRolloutName() }));
uiNotification.displayValidationError(
i18n.get("message.rollout.duplicate.check", new Object[] { getRolloutName() }));
return false;
}
return true;
@@ -580,9 +582,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
}
private TextArea createDescription() {
final TextArea descriptionField = SPUIComponentProvider.getTextArea("text-area-style",
ValoTheme.TEXTFIELD_TINY, false, null, i18n.get("textfield.description"),
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
final TextArea descriptionField = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTFIELD_TINY,
false, null, i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
descriptionField.setId(SPUIComponetIdProvider.ROLLOUT_DESCRIPTION_ID);
descriptionField.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
descriptionField.setSizeFull();
@@ -647,8 +648,9 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
private Container createDsComboContainer() {
final BeanQueryFactory<DistBeanQuery> distributionQF = new BeanQueryFactory<>(DistBeanQuery.class);
return new LazyQueryContainer(new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE,
SPUILabelDefinitions.VAR_DIST_ID_NAME), distributionQF);
return new LazyQueryContainer(
new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME),
distributionQF);
}
@@ -682,8 +684,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
try {
if (HawkbitCommonUtil.trimAndNullIfEmpty(noOfGroups.getValue()) == null
|| HawkbitCommonUtil.trimAndNullIfEmpty((String) targetFilterQueryCombo.getValue()) == null) {
uiNotification.displayValidationError(i18n
.get("message.rollout.noofgroups.or.targetfilter.missing"));
uiNotification
.displayValidationError(i18n.get("message.rollout.noofgroups.or.targetfilter.missing"));
} else {
new RegexpValidator(NUMBER_REGEXP, i18n.get(MESSAGE_ENTER_NUMBER)).validate(value);
final int groupSize = getGroupSize();
@@ -708,8 +710,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
public void validate(final Object value) {
try {
new RegexpValidator(NUMBER_REGEXP, i18n.get(MESSAGE_ENTER_NUMBER)).validate(value);
new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 100), 0, 100).validate(Integer
.valueOf(value.toString()));
new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 100), 0, 100)
.validate(Integer.valueOf(value.toString()));
} catch (final InvalidValueException ex) {
throw ex;
}
@@ -723,8 +725,8 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
public void validate(final Object value) {
try {
new RegexpValidator(NUMBER_REGEXP, i18n.get(MESSAGE_ENTER_NUMBER)).validate(value);
new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 500), 0, 500).validate(Integer
.valueOf(value.toString()));
new IntegerRangeValidator(i18n.get(MESSAGE_ROLLOUT_FIELD_VALUE_RANGE, 0, 500), 0, 500)
.validate(Integer.valueOf(value.toString()));
} catch (final InvalidValueException ex) {
throw ex;
}
@@ -740,7 +742,7 @@ public class AddUpdateRolloutWindowLayout extends CustomComponent {
*/
public void populateData(final Long rolloutId) {
resetComponents();
editRollout = Boolean.TRUE;
editRolloutEnabled = Boolean.TRUE;
rolloutForEdit = rolloutManagement.findRolloutById(rolloutId);
rolloutName.setValue(rolloutForEdit.getName());
description.setValue(rolloutForEdit.getDescription());

View File

@@ -86,7 +86,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
gatewayTokenNameTextField.setImmediate(true);
// hide text field until we support multiple gateway tokens for a tenan
gatewayTokenNameTextField.setVisible(false);
gatewayTokenNameTextField.addTextChangeListener(event -> keyNameChanged());
gatewayTokenNameTextField.addTextChangeListener(event -> doKeyNameChanged());
final Button gatewaytokenBtn = SPUIComponentProvider.getButton("TODO-ID", "Regenerate Key", "",
ValoTheme.BUTTON_TINY + " " + "redicon", true, null, SPUIButtonStyleSmall.class);
@@ -116,10 +116,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
}
}
/**
* @return
*/
private void keyNameChanged() {
private void doKeyNameChanged() {
keyNameChanged = true;
notifyConfigurationChanged();
}