Remove swagger and minor feature extensions and bug fixes
- Various Bug fixes and improvements - Management API extended - Swagger removed - Guava Upgraded to 19
This commit is contained in:
0
examples/README.md
Executable file → Normal file
0
examples/README.md
Executable file → Normal file
0
examples/hawkbit-device-simulator/.gitignore
vendored
Executable file → Normal file
0
examples/hawkbit-device-simulator/.gitignore
vendored
Executable file → Normal file
23
examples/hawkbit-device-simulator/README.md
Executable file → Normal file
23
examples/hawkbit-device-simulator/README.md
Executable file → Normal file
@@ -11,8 +11,29 @@ Or:
|
||||
run org.eclipse.hawkbit.simulator.DeviceSimulator
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
The simulator has user authentication enabled by default. Default credentials:
|
||||
* username : admin
|
||||
* passwd : admin
|
||||
|
||||
This can be configured/disabled by spring boot properties
|
||||
|
||||
## Usage
|
||||
The device simulator exposes an REST-API which can be used to trigger device creation.
|
||||
|
||||
Optional parameters:
|
||||
* name : name prefix simulated devices (default: "dmfSimulated"), followed by counter
|
||||
* amount : number of simulated devices (default: 20, capped at: 4000)
|
||||
* tenant : in a multi-tenenat ready hawkBit installation (default: "DEFAULT")
|
||||
|
||||
|
||||
Example: for 20 simulated devices (default)
|
||||
```
|
||||
http://localhost:8083/start?amount=10
|
||||
http://localhost:8083/start
|
||||
```
|
||||
|
||||
Example: for 10 simulated devices that start with the name prefix "activeSim":
|
||||
```
|
||||
http://localhost:8083/start?amount=10&name=activeSim
|
||||
```
|
||||
|
||||
118
examples/hawkbit-device-simulator/pom.xml
Executable file → Normal file
118
examples/hawkbit-device-simulator/pom.xml
Executable file → Normal file
@@ -9,53 +9,81 @@
|
||||
http://www.eclipse.org/legal/epl-v10.html
|
||||
|
||||
-->
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<artifactId>hawkbit-examples-parent</artifactId>
|
||||
</parent>
|
||||
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<artifactId>hawkbit-examples-parent</artifactId>
|
||||
</parent>
|
||||
<artifactId>hawkbit-device-simulator</artifactId>
|
||||
<name>hawkBit :: Device Simulator</name>
|
||||
<description>Device Management Federation API based simulator</description>
|
||||
|
||||
<artifactId>hawkbit-device-simulator</artifactId>
|
||||
<name>hawkBit :: Device Simulator</name>
|
||||
<description>Device Management Federation API based simulator</description>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${baseDir}</outputDirectory>
|
||||
<addResources>false</addResources>
|
||||
<mainClass>org.eclipse.hawkbit.simulator.DeviceSimulator</mainClass>
|
||||
<layout>JAR</layout>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-dmf-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.amqp</groupId>
|
||||
<artifactId>spring-rabbit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-dmf-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.amqp</groupId>
|
||||
<artifactId>spring-rabbit</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-config</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-logging</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-log4j2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
4
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulator.java
Executable file → Normal file
4
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulator.java
Executable file → Normal file
@@ -20,6 +20,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
@SpringBootApplication
|
||||
public class DeviceSimulator {
|
||||
|
||||
private DeviceSimulator() {
|
||||
// utility class
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the Spring Boot Application.
|
||||
*
|
||||
|
||||
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulationController.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulationController.java
Executable file → Normal file
18
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java
Executable file → Normal file
18
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java
Executable file → Normal file
@@ -48,7 +48,7 @@ public class AmqpConfiguration {
|
||||
|
||||
/**
|
||||
* Create jackson message converter bean.
|
||||
*
|
||||
*
|
||||
* @return the jackson message converter
|
||||
*/
|
||||
@Bean
|
||||
@@ -60,7 +60,7 @@ public class AmqpConfiguration {
|
||||
|
||||
/**
|
||||
* Create the receiver queue from sp. Receive messages from sp.
|
||||
*
|
||||
*
|
||||
* @return the queue
|
||||
*/
|
||||
@Bean
|
||||
@@ -71,7 +71,7 @@ public class AmqpConfiguration {
|
||||
|
||||
/**
|
||||
* Create the recevier exchange. Sp send messages to this exchange.
|
||||
*
|
||||
*
|
||||
* @return the exchange
|
||||
*/
|
||||
@Bean
|
||||
@@ -83,7 +83,7 @@ public class AmqpConfiguration {
|
||||
* Create the Binding
|
||||
* {@link AmqpConfiguration#receiverConnectorQueueFromSp()} to
|
||||
* {@link AmqpConfiguration#exchangeQueueToConnector()}.
|
||||
*
|
||||
*
|
||||
* @return the binding and create the queue and exchange
|
||||
*/
|
||||
@Bean
|
||||
@@ -93,7 +93,7 @@ public class AmqpConfiguration {
|
||||
|
||||
/**
|
||||
* Create dead letter queue.
|
||||
*
|
||||
*
|
||||
* @return the queue
|
||||
*/
|
||||
@Bean
|
||||
@@ -103,7 +103,7 @@ public class AmqpConfiguration {
|
||||
|
||||
/**
|
||||
* Create the dead letter fanout exchange.
|
||||
*
|
||||
*
|
||||
* @return the fanout exchange
|
||||
*/
|
||||
@Bean
|
||||
@@ -113,7 +113,7 @@ public class AmqpConfiguration {
|
||||
|
||||
/**
|
||||
* Create the Binding deadLetterQueue to exchangeDeadLetter.
|
||||
*
|
||||
*
|
||||
* @return the binding
|
||||
*/
|
||||
@Bean
|
||||
@@ -123,7 +123,7 @@ public class AmqpConfiguration {
|
||||
|
||||
/**
|
||||
* Returns the Listener factory.
|
||||
*
|
||||
*
|
||||
* @return the {@link SimpleMessageListenerContainer} that gets used receive
|
||||
* AMQP messages
|
||||
*/
|
||||
@@ -136,7 +136,7 @@ public class AmqpConfiguration {
|
||||
}
|
||||
|
||||
private Map<String, Object> getDeadLetterExchangeArgs() {
|
||||
final Map<String, Object> args = new HashMap<String, Object>();
|
||||
final Map<String, Object> args = new HashMap<>();
|
||||
args.put("x-dead-letter-exchange", amqpProperties.getDeadLetterExchange());
|
||||
return args;
|
||||
}
|
||||
|
||||
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageHandlerCacheConstant.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageHandlerCacheConstant.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageService.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageService.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/ReceiverService.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/ReceiverService.java
Executable file → Normal file
2
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SenderService.java
Executable file → Normal file
2
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SenderService.java
Executable file → Normal file
@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.simulator.amqp;
|
||||
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.AbstractJavaTypeMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
@@ -48,6 +49,7 @@ public abstract class SenderService extends MessageService {
|
||||
if (message == null) {
|
||||
return;
|
||||
}
|
||||
message.getMessageProperties().getHeaders().remove(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME);
|
||||
rabbitTemplate.setExchange(adress);
|
||||
rabbitTemplate.send(message);
|
||||
}
|
||||
|
||||
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SimulatedUpdate.java
Executable file → Normal file
0
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SimulatedUpdate.java
Executable file → Normal file
12
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java
Executable file → Normal file
12
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java
Executable file → Normal file
@@ -131,11 +131,23 @@ 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);
|
||||
|
||||
final SimulatedUpdate update = new SimulatedUpdate(tenant, thingId, actionId);
|
||||
|
||||
try {
|
||||
Thread.sleep(1_000);
|
||||
} catch (final InterruptedException e) {
|
||||
LOGGER.error("Sleep interrupted", e);
|
||||
}
|
||||
|
||||
spSenderService.finishUpdateProcess(update, "Simulation complete!");
|
||||
}
|
||||
|
||||
|
||||
4
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java
Executable file → Normal file
4
examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java
Executable file → Normal file
@@ -216,9 +216,7 @@ public class SpSenderService extends SenderService {
|
||||
|
||||
private Message createActionStatusMessage(final SimulatedUpdate update, final String messageDescription,
|
||||
final ActionStatus status) {
|
||||
final Message sendMessage = createActionStatusMessage(update.getTenant(), status, messageDescription,
|
||||
update.getActionId());
|
||||
return sendMessage;
|
||||
return createActionStatusMessage(update.getTenant(), status, messageDescription, update.getActionId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
56
examples/hawkbit-device-simulator/src/main/resources/application.properties
Executable file → Normal file
56
examples/hawkbit-device-simulator/src/main/resources/application.properties
Executable file → Normal file
@@ -12,7 +12,7 @@
|
||||
# PUBLIC configuration, i.e. can be changed by users at runtime (defaults provided here)
|
||||
#########################################################################################
|
||||
## Configuration for RabbitMQ communication
|
||||
hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp=sp_connector_receiver
|
||||
hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp=simulator_receiver
|
||||
hawkbit.device.simulator.amqp.deadLetterQueue=simulator_deadletter
|
||||
hawkbit.device.simulator.amqp.deadLetterExchange=simulator.deadletter
|
||||
hawkbit.device.simulator.amqp.senderForSpExchange=simulator.replyTo
|
||||
@@ -27,58 +27,6 @@ spring.rabbitmq.port=5672
|
||||
spring.rabbitmq.dynamic=true
|
||||
|
||||
|
||||
#disable expose jmx beans
|
||||
spring.jmx.enabled=false
|
||||
# the context path of the monitor spring actuator which offers following endpoints
|
||||
# /autoconfig, /beans, /configprops, /dump, /env, /health, /info, /metrics, /mappings, /trace
|
||||
management.context-path=/system
|
||||
management.security.enabled=true
|
||||
management.security.sessions=stateless
|
||||
# ENDPOINTS
|
||||
endpoints.autoconfig.id=autoconfig
|
||||
endpoints.autoconfig.sensitive=true
|
||||
endpoints.autoconfig.enabled=false
|
||||
endpoints.beans.id=beans
|
||||
endpoints.beans.sensitive=true
|
||||
endpoints.beans.enabled=false
|
||||
endpoints.configprops.id=configprops
|
||||
endpoints.configprops.sensitive=true
|
||||
endpoints.configprops.enabled=true
|
||||
#endpoints.configprops.keys-to-sanitize=password,secret,key # suffix or regex
|
||||
endpoints.dump.id=dump
|
||||
endpoints.dump.sensitive=true
|
||||
endpoints.dump.enabled=false
|
||||
endpoints.env.id=env
|
||||
endpoints.env.sensitive=true
|
||||
endpoints.env.enabled=true
|
||||
#endpoints.env.keys-to-sanitize=password,secret,key # suffix or regex
|
||||
endpoints.health.id=health
|
||||
endpoints.health.sensitive=true
|
||||
endpoints.health.enabled=true
|
||||
endpoints.info.id=info
|
||||
endpoints.info.sensitive=true
|
||||
endpoints.info.enabled=true
|
||||
endpoints.metrics.id=metrics
|
||||
endpoints.metrics.sensitive=true
|
||||
endpoints.metrics.enabled=true
|
||||
endpoints.shutdown.id=shutdown
|
||||
endpoints.shutdown.sensitive=true
|
||||
endpoints.shutdown.enabled=false
|
||||
endpoints.trace.id=trace
|
||||
endpoints.trace.sensitive=true
|
||||
endpoints.trace.enabled=true
|
||||
|
||||
# HEALTH INDICATORS (previously health.*)
|
||||
management.health.db.enabled=true
|
||||
management.health.diskspace.enabled=true
|
||||
management.health.mongo.enabled=true
|
||||
management.health.rabbit.enabled=true
|
||||
management.health.redis.enabled=false
|
||||
management.health.solr.enabled=false
|
||||
management.health.diskspace.path=.
|
||||
management.health.diskspace.threshold=10485760
|
||||
management.health.status.order=DOWN, OUT_OF_SERVICE, UNKNOWN, UP
|
||||
|
||||
# SECURITY (SecurityProperties)
|
||||
security.user.name=${BASIC_USERNAME:admin}
|
||||
security.user.password=${BASIC_PASSWORD:admin}
|
||||
@@ -87,7 +35,7 @@ security.require-ssl=false
|
||||
security.enable-csrf=false
|
||||
security.basic.enabled=true
|
||||
security.basic.realm=DeviceSimulator
|
||||
security.basic.path= /system/**
|
||||
security.basic.path= /**
|
||||
security.basic.authorize-mode=ROLE
|
||||
security.filter-order=0
|
||||
security.headers.xss=false
|
||||
|
||||
0
examples/hawkbit-example-app/.gitignore
vendored
Executable file → Normal file
0
examples/hawkbit-example-app/.gitignore
vendored
Executable file → Normal file
0
examples/hawkbit-example-app/README.md
Executable file → Normal file
0
examples/hawkbit-example-app/README.md
Executable file → Normal file
9
examples/hawkbit-example-app/pom.xml
Executable file → Normal file
9
examples/hawkbit-example-app/pom.xml
Executable file → Normal file
@@ -48,6 +48,11 @@
|
||||
<artifactId>hawkbit-autoconfigure</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-rest-resource</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-dmf-amqp</artifactId>
|
||||
@@ -92,10 +97,6 @@
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-aspects</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
|
||||
0
examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/MyLoginUI.java
Executable file → Normal file
0
examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/MyLoginUI.java
Executable file → Normal file
0
examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/MyUI.java
Executable file → Normal file
0
examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/MyUI.java
Executable file → Normal file
12
examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/Start.java
Executable file → Normal file
12
examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/Start.java
Executable file → Normal file
@@ -10,25 +10,27 @@ package org.eclipse.hawkbit.app;
|
||||
|
||||
import org.eclipse.hawkbit.RepositoryApplicationConfiguration;
|
||||
import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration;
|
||||
import org.eclipse.hawkbit.controller.EnableDirectDeviceApi;
|
||||
import org.eclipse.hawkbit.rest.resource.EnableRestResources;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
/**
|
||||
* A {@link SpringBootApplication} annoated class with a main method to start.
|
||||
* The minimal configuration for the standalone hawkBit server.
|
||||
*
|
||||
*
|
||||
* A {@link SpringBootApplication} annotated class with a main method to start.
|
||||
* The minimal configuration for the stand alone hawkBit server.
|
||||
*
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@Import({ RepositoryApplicationConfiguration.class })
|
||||
@EnableHawkbitManagedSecurityConfiguration
|
||||
@EnableRestResources
|
||||
@EnableDirectDeviceApi
|
||||
public class Start {
|
||||
|
||||
/**
|
||||
* Main method to start the spring-boot application.
|
||||
*
|
||||
*
|
||||
* @param args
|
||||
* the VM arguments.
|
||||
*/
|
||||
|
||||
0
examples/hawkbit-example-app/src/main/resources/application.properties
Executable file → Normal file
0
examples/hawkbit-example-app/src/main/resources/application.properties
Executable file → Normal file
2
examples/hawkbit-mgmt-api-client/.gitignore
vendored
Normal file
2
examples/hawkbit-mgmt-api-client/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/target/
|
||||
/bin/
|
||||
3
examples/hawkbit-mgmt-api-client/README.md
Normal file
3
examples/hawkbit-mgmt-api-client/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
Example client that shows how to efficiently use the hawkBit management API.
|
||||
|
||||
Powered by [Feign](https://github.com/Netflix/feign).
|
||||
70
examples/hawkbit-mgmt-api-client/pom.xml
Normal file
70
examples/hawkbit-mgmt-api-client/pom.xml
Normal file
@@ -0,0 +1,70 @@
|
||||
<!--
|
||||
|
||||
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
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-examples-parent</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>hawkbit-mgmt-api-client</artifactId>
|
||||
<name>hawkBit Management API example client</name>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-rest-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-jackson</artifactId>
|
||||
<version>8.12.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.netflix.feign</groupId>
|
||||
<artifactId>feign-core</artifactId>
|
||||
<version>8.12.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Test -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-example-app</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.yandex.qatools.allure</groupId>
|
||||
<artifactId>allure-junit-adaptor</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easytesting</groupId>
|
||||
<artifactId>fest-assert-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.easytesting</groupId>
|
||||
<artifactId>fest-assert</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 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.mgmt.api.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.RestConstants;
|
||||
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPost;
|
||||
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetsRest;
|
||||
|
||||
import feign.Headers;
|
||||
import feign.RequestLine;
|
||||
|
||||
/**
|
||||
* Client binding for the Distribution resource of the management API.
|
||||
*/
|
||||
public interface DistributionSetResource {
|
||||
|
||||
/**
|
||||
* Creates a list of distrbution sets.
|
||||
*
|
||||
* @param sets
|
||||
* the request body java bean containing the necessary attributes
|
||||
* for creating a distribution set.
|
||||
* @return the list of targets which have been created
|
||||
*/
|
||||
@RequestLine("POST " + RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)
|
||||
@Headers("Content-Type: application/json")
|
||||
DistributionSetsRest createDistributionSets(final List<DistributionSetRequestBodyPost> sets);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* 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.mgmt.api.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.RestConstants;
|
||||
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetsRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.AssignedDistributionSetRequestBody;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.DistributionSetTagAssigmentResultRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest;
|
||||
|
||||
import feign.Headers;
|
||||
import feign.Param;
|
||||
import feign.RequestLine;
|
||||
|
||||
/**
|
||||
* Client binding for the DistributionSetTag resource of the management API.
|
||||
*/
|
||||
public interface DistrubutionSetTagResource {
|
||||
|
||||
/**
|
||||
* Retrieves a single distributionset tag based on the given ID.
|
||||
*
|
||||
* @param dsTagId
|
||||
* the ID of the distributionset tag to retrieve
|
||||
* @return a deserialized java bean containing the attributes of the
|
||||
* returned distributionset tag
|
||||
*/
|
||||
@RequestLine("GET " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{dsTagId}")
|
||||
TagRest getDistributionSetTag(@Param("dsTagId") Long dsTagId);
|
||||
|
||||
/**
|
||||
* Creates a list of distributionset tags.
|
||||
*
|
||||
* @param tags
|
||||
* the tags to be created
|
||||
* @return the created tag list
|
||||
*/
|
||||
@RequestLine("POST " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING)
|
||||
@Headers("Content-Type: application/json")
|
||||
TagsRest createDistributionSetTags(List<TagRequestBodyPut> tags);
|
||||
|
||||
/**
|
||||
* Update attributes of a distributionset tag.
|
||||
*
|
||||
* @param dsTagId
|
||||
* the distributionset tag id to be updated
|
||||
* @param tag
|
||||
* the request body
|
||||
* @return the updated distributionset tag
|
||||
*/
|
||||
@RequestLine("PUT " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{dsTagId}")
|
||||
@Headers("Content-Type: application/json")
|
||||
TagRest updateDistributionSetTag(@Param("dsTagId") Long dsTagId, TagRequestBodyPut tag);
|
||||
|
||||
/**
|
||||
* Deletes given distributionset tag on given ID.
|
||||
*
|
||||
* @param dsTagId
|
||||
* to be deleted
|
||||
*/
|
||||
@RequestLine("DELETE " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{dsTagId}")
|
||||
void deleteDistributionSetTag(@Param("dsTagId") final Long dsTagId);
|
||||
|
||||
/**
|
||||
* Retrieves a all assigned targets on the given distributionset tag id.
|
||||
*
|
||||
* @param dsTagId
|
||||
* the ID of the distributionset tag to retrieve
|
||||
* @return a list of targets
|
||||
*/
|
||||
@RequestLine("GET " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING
|
||||
+ RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING)
|
||||
DistributionSetsRest getAssignedDistributionSets(@Param("dsTagId") final Long dsTagId);
|
||||
|
||||
/**
|
||||
* Toggle the tag assignment all assigned targets will be unassigned and all
|
||||
* unassigned targets will be assigned.
|
||||
*
|
||||
* @param dsTagId
|
||||
* the ID of the distributionset tag to toggle
|
||||
* @param assignedTargetRequestBodies
|
||||
* a list of controller ids
|
||||
* @return a list of assigned and unassigned targets
|
||||
*/
|
||||
@RequestLine("POST " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING
|
||||
+ RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING + "/toggleTagAssignment")
|
||||
@Headers("Content-Type: application/json")
|
||||
DistributionSetTagAssigmentResultRest toggleTagAssignment(@Param("dsTagId") final Long dsTagId,
|
||||
final List<AssignedDistributionSetRequestBody> assignedTargetRequestBodies);
|
||||
|
||||
/**
|
||||
* Assign targets to a given distributionset tag id.
|
||||
*
|
||||
* @param dsTagId
|
||||
* the ID of the distributionset tag to add the targets
|
||||
* @param assignedTargetRequestBodies
|
||||
* a list of controller ids
|
||||
* @return a list of assigned targets
|
||||
*/
|
||||
@RequestLine("POST " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING
|
||||
+ RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING)
|
||||
@Headers("Content-Type: application/json")
|
||||
TargetsRest assignDistributionSets(@Param("dsTagId") final Long dsTagId,
|
||||
final List<AssignedDistributionSetRequestBody> assignedTargetRequestBodies);
|
||||
|
||||
/**
|
||||
* Unassign targets to a given distributionset tag id.
|
||||
*
|
||||
* @param dsTagId
|
||||
* the ID of the distributionset tag to add the targets
|
||||
*/
|
||||
@RequestLine("DELETE " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING
|
||||
+ RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING)
|
||||
void unassignDistributionSets(@Param("dsTagId") final Long dsTagId);
|
||||
|
||||
/**
|
||||
* Unassign one target to a given distributionset tag id.
|
||||
*
|
||||
* @param dsTagId
|
||||
* the ID of the distributionset tag to add the targets param
|
||||
* @param dsId
|
||||
* the distributionset id
|
||||
*/
|
||||
@RequestLine("DELETE " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING
|
||||
+ RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING + "/{dsId}")
|
||||
void unassignDistributionSet(@Param("dsTagId") final Long dsTagId, @Param("dsId") final Long dsId);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* 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.mgmt.api.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetPagedList;
|
||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody;
|
||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest;
|
||||
|
||||
import feign.Headers;
|
||||
import feign.Param;
|
||||
import feign.RequestLine;
|
||||
|
||||
/**
|
||||
* Client binding for the Target resource of the management API.
|
||||
*/
|
||||
public interface TargetResource {
|
||||
|
||||
/**
|
||||
* Retrieves a single target based on the given ID.
|
||||
*
|
||||
* @param targetId
|
||||
* the ID of the target to retrieve
|
||||
* @return a deserialized java bean containing the attributes of the
|
||||
* returned target
|
||||
*/
|
||||
@RequestLine("GET /rest/v1/targets/{targetId}")
|
||||
TargetRest getTarget(@Param("targetId") final String targetId);
|
||||
|
||||
/**
|
||||
* Paged query of targets resource.
|
||||
*
|
||||
* @param pagingOffsetParam
|
||||
* of the paged query
|
||||
* @param pagingLimitParam
|
||||
* of the paged query
|
||||
* @return paged list of target entries
|
||||
*/
|
||||
@RequestLine("GET /rest/v1/targets?offset={pagingOffsetParam}&limit={pagingLimitParam}")
|
||||
TargetPagedList getTargets(@Param("pagingOffsetParam") int pagingOffsetParam,
|
||||
@Param("pagingLimitParam") int pagingLimitParam);
|
||||
|
||||
/**
|
||||
* Paged query of targets resource with default offset and limit.
|
||||
*
|
||||
* @return paged list of target entries
|
||||
*/
|
||||
@RequestLine("GET /rest/v1/targets")
|
||||
TargetPagedList getTargets();
|
||||
|
||||
/**
|
||||
* Deletes given target based on given ID.
|
||||
*
|
||||
* @param targetId
|
||||
* to be deleted
|
||||
*/
|
||||
@RequestLine("DELETE /rest/v1/targets/{targetId}")
|
||||
void deleteTarget(@Param("targetId") final String targetId);
|
||||
|
||||
/**
|
||||
* Creates a list of targets.
|
||||
*
|
||||
* @param targets
|
||||
* the request body java bean containing the necessary attributes
|
||||
* for creating a target.
|
||||
* @return the list of targets which have been created
|
||||
*/
|
||||
@RequestLine("POST /rest/v1/targets/")
|
||||
@Headers("Content-Type: application/json")
|
||||
TargetsRest createTargets(List<TargetRequestBody> targets);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* 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.mgmt.api.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.rest.resource.RestConstants;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.AssignedTargetRequestBody;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TargetTagAssigmentResultRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest;
|
||||
|
||||
import feign.Headers;
|
||||
import feign.Param;
|
||||
import feign.RequestLine;
|
||||
|
||||
/**
|
||||
* Client binding for the Target resource of the management API.
|
||||
*/
|
||||
public interface TargetTagResource {
|
||||
|
||||
/**
|
||||
* Retrieves a single target tag based on the given ID.
|
||||
*
|
||||
* @param targetTagId
|
||||
* the ID of the target tag to retrieve
|
||||
* @return a deserialized java bean containing the attributes of the
|
||||
* returned target tag
|
||||
*/
|
||||
@RequestLine("GET " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}")
|
||||
TagRest getTargetTag(@Param("targetTagId") Long targetTagId);
|
||||
|
||||
/**
|
||||
* Creates a list of target tags.
|
||||
*
|
||||
* @param tags
|
||||
* the tags to be created
|
||||
* @return the created tag list
|
||||
*/
|
||||
@RequestLine("POST " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING)
|
||||
@Headers("Content-Type: application/json")
|
||||
TagsRest createTargetTag(List<TagRequestBodyPut> tags);
|
||||
|
||||
/**
|
||||
* Update attributes of a target tag.
|
||||
*
|
||||
* @param targetTagId
|
||||
* the target tag id to be updated
|
||||
* @param tag
|
||||
* the request body
|
||||
* @return the updated target tag
|
||||
*/
|
||||
@RequestLine("PUT " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}")
|
||||
@Headers("Content-Type: application/json")
|
||||
TagRest updateTagretTag(@Param("targetTagId") Long targetTagId, TagRequestBodyPut tag);
|
||||
|
||||
/**
|
||||
* Deletes given target tag on given ID.
|
||||
*
|
||||
* @param targetTagId
|
||||
* to be deleted
|
||||
*/
|
||||
@RequestLine("DELETE " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}")
|
||||
void deleteTargetTag(@Param("targetTagId") final Long targetTagId);
|
||||
|
||||
/**
|
||||
* Retrieves a all assigned targets on the given target tag id.
|
||||
*
|
||||
* @param targetTagId
|
||||
* the ID of the target tag to retrieve
|
||||
* @return a list of targets
|
||||
*/
|
||||
@RequestLine("GET " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING
|
||||
+ RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING)
|
||||
TargetsRest getAssignedTargets(@Param("targetTagId") final Long targetTagId);
|
||||
|
||||
/**
|
||||
* Toggle the tag assignment all assigned targets will be unassigned and all
|
||||
* unassigned targets will be assigned.
|
||||
*
|
||||
* @param targetTagId
|
||||
* the ID of the target tag to toggle
|
||||
* @param assignedTargetRequestBodies
|
||||
* a list of controller ids
|
||||
* @return a list of assigned and unassigned targets
|
||||
*/
|
||||
@RequestLine("POST " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING
|
||||
+ RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING + "/toggleTagAssignment")
|
||||
@Headers("Content-Type: application/json")
|
||||
TargetTagAssigmentResultRest toggleTagAssignment(@Param("targetTagId") final Long targetTagId,
|
||||
final List<AssignedTargetRequestBody> assignedTargetRequestBodies);
|
||||
|
||||
/**
|
||||
* Assign targets to a given target tag id.
|
||||
*
|
||||
* @param targetTagId
|
||||
* the ID of the target tag to add the targets
|
||||
* @param assignedTargetRequestBodies
|
||||
* a list of controller ids
|
||||
* @return a list of assigned targets
|
||||
*/
|
||||
@RequestLine("POST " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING
|
||||
+ RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING)
|
||||
@Headers("Content-Type: application/json")
|
||||
TargetsRest assignTargets(@Param("targetTagId") final Long targetTagId,
|
||||
final List<AssignedTargetRequestBody> assignedTargetRequestBodies);
|
||||
|
||||
/**
|
||||
* Unassign targets to a given target tag id.
|
||||
*
|
||||
* @param targetTagId
|
||||
* the ID of the target tag to add the targets
|
||||
*/
|
||||
@RequestLine("DELETE " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING
|
||||
+ RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING)
|
||||
void unassignTargets(@Param("targetTagId") final Long targetTagId);
|
||||
|
||||
/**
|
||||
* Unassign one target to a given target tag id.
|
||||
*
|
||||
* @param targetTagId
|
||||
* the ID of the target tag to add the targets param
|
||||
* @param controllerId
|
||||
* the controller id
|
||||
*/
|
||||
@RequestLine("DELETE " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING
|
||||
+ RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING + "/{controllerId}")
|
||||
void unassignTarget(@Param("targetTagId") final Long targetTagId, @Param("controllerId") final String controllerId);
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
/**
|
||||
* 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.mgmt.api.client;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.app.Start;
|
||||
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPost;
|
||||
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetsRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.AssignedDistributionSetRequestBody;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.DistributionSetTagAssigmentResultRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.context.annotation.Description;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
import feign.Feign;
|
||||
import feign.Logger;
|
||||
import feign.auth.BasicAuthRequestInterceptor;
|
||||
import feign.jackson.JacksonDecoder;
|
||||
import feign.jackson.JacksonEncoder;
|
||||
|
||||
@Features("Example Tests - Management RESTful API Client")
|
||||
@Stories("DistrubutionSet Tag Resource")
|
||||
public class DistributionSetTagTest {
|
||||
|
||||
private DistrubutionSetTagResource distrubutionSetTagResource;
|
||||
|
||||
private static List<AssignedDistributionSetRequestBody> assignedTargetRequestBodies;
|
||||
|
||||
@BeforeClass
|
||||
public static void startupServer() {
|
||||
SpringApplication.run(Start.class, new String[0]);
|
||||
createTargetsAssignment();
|
||||
assignedTargetRequestBodies.add(new AssignedDistributionSetRequestBody().setDistributionSetId(100L));
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.distrubutionSetTagResource = createDistrubutionSetTagResource();
|
||||
}
|
||||
|
||||
// disabled as this runs not on CI environments.
|
||||
@Test
|
||||
@Description("Simple request of distrubutionset tag by ID")
|
||||
@Ignore
|
||||
public void getDistributionSetTag() {
|
||||
final TagsRest result = createDistributionSetTags(2);
|
||||
|
||||
assertThat(distrubutionSetTagResource.getDistributionSetTag(result.get(0).getTagId()).getName()).isEqualTo(
|
||||
"Tag0");
|
||||
|
||||
deleteDistributionSets(result);
|
||||
}
|
||||
|
||||
// disabled as this runs not on CI environments.
|
||||
@Test
|
||||
@Description("Simple update of a distrubutionset tag")
|
||||
@Ignore
|
||||
public void updateDistributionSetTag() {
|
||||
final TagsRest created = createDistributionSetTags(10);
|
||||
|
||||
distrubutionSetTagResource.updateDistributionSetTag(created.get(0).getTagId(), new TagRequestBodyPut()
|
||||
.setDescription("Test").setName("Test").setColour("Green"));
|
||||
|
||||
final TagRest targetTag = distrubutionSetTagResource.getDistributionSetTag(created.get(0).getTagId());
|
||||
assertThat(targetTag.getName()).isEqualTo("Test");
|
||||
assertThat(targetTag.getDescription()).isEqualTo("Test");
|
||||
assertThat(targetTag.getColour()).isEqualTo("Green");
|
||||
|
||||
deleteDistributionSets(created);
|
||||
}
|
||||
|
||||
// disabled as this runs not on CI environments.
|
||||
@Test
|
||||
@Description("Simple request of all assigned distrubutionsets by a distrubutionset tag.")
|
||||
@Ignore
|
||||
public void getDistributionSetByTagId() {
|
||||
final TagsRest created = createDistributionSetTags(10);
|
||||
distrubutionSetTagResource.assignDistributionSets(created.get(2).getTagId(), assignedTargetRequestBodies);
|
||||
|
||||
final DistributionSetsRest distributionSetsRest = distrubutionSetTagResource
|
||||
.getAssignedDistributionSets(created.get(2).getTagId());
|
||||
assertThat(distributionSetsRest).hasSize(5);
|
||||
|
||||
distrubutionSetTagResource.unassignDistributionSets(created.get(2).getTagId());
|
||||
deleteDistributionSets(created);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Toggle request to unassigned all assigned distrubutionset and assign all unassigned distrubutionset.")
|
||||
@Ignore
|
||||
public void toggleTagAssignment() {
|
||||
final TagsRest created = createDistributionSetTags(10);
|
||||
final Long id = created.get(2).getTagId();
|
||||
|
||||
distrubutionSetTagResource.assignDistributionSets(id, assignedTargetRequestBodies);
|
||||
distrubutionSetTagResource.unassignDistributionSet(id, assignedTargetRequestBodies.get(0)
|
||||
.getDistributionSetId());
|
||||
|
||||
DistributionSetTagAssigmentResultRest assigmentResultRest = distrubutionSetTagResource.toggleTagAssignment(id,
|
||||
assignedTargetRequestBodies);
|
||||
|
||||
final TagRest targetTag = distrubutionSetTagResource.getDistributionSetTag(created.get(2).getTagId());
|
||||
assertThat(assigmentResultRest.getAssignedDistributionSets()).hasSize(1);
|
||||
assertThat(assigmentResultRest.getUnassignedDistributionSets()).hasSize(0);
|
||||
|
||||
assigmentResultRest = distrubutionSetTagResource.toggleTagAssignment(id, assignedTargetRequestBodies);
|
||||
assertThat(assigmentResultRest.getAssignedDistributionSets()).hasSize(0);
|
||||
assertThat(assigmentResultRest.getUnassignedDistributionSets()).hasSize(5);
|
||||
|
||||
distrubutionSetTagResource.unassignDistributionSets(targetTag.getTagId());
|
||||
deleteDistributionSets(created);
|
||||
}
|
||||
|
||||
private void deleteDistributionSets(final List<TagRest> tags) {
|
||||
for (final TagRest tag : tags) {
|
||||
distrubutionSetTagResource.deleteDistributionSetTag(tag.getTagId());
|
||||
}
|
||||
}
|
||||
|
||||
private TagsRest createDistributionSetTags(final int number) {
|
||||
|
||||
final List<TagRequestBodyPut> tags = new ArrayList<>();
|
||||
for (int i = 0; i < number; i++) {
|
||||
tags.add(new TagRequestBodyPut().setDescription("Tag " + i).setName("Tag" + i).setColour("Red"));
|
||||
}
|
||||
|
||||
final TagsRest result = distrubutionSetTagResource.createDistributionSetTags(tags);
|
||||
|
||||
assertThat(result).hasSize(number);
|
||||
return result;
|
||||
}
|
||||
|
||||
private DistrubutionSetTagResource createDistrubutionSetTagResource() {
|
||||
final DistrubutionSetTagResource distrubutionSetTagResource = Feign.builder().logger(new Logger.ErrorLogger())
|
||||
.logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder())
|
||||
.requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin"))
|
||||
.target(DistrubutionSetTagResource.class, "http://localhost:8080");
|
||||
return distrubutionSetTagResource;
|
||||
}
|
||||
|
||||
private static void createTargetsAssignment() {
|
||||
|
||||
final List<DistributionSetRequestBodyPost> sets = new ArrayList<>();
|
||||
assignedTargetRequestBodies = new ArrayList<>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
final DistributionSetRequestBodyPost bodyPost = (DistributionSetRequestBodyPost) new DistributionSetRequestBodyPost()
|
||||
.setName("Ds" + i).setDescription("Ds" + i).setVersion("" + i);
|
||||
sets.add(bodyPost);
|
||||
}
|
||||
|
||||
final DistributionSetsRest result = createDistributionSetResource().createDistributionSets(sets);
|
||||
for (final DistributionSetRest rest : result) {
|
||||
assignedTargetRequestBodies.add(new AssignedDistributionSetRequestBody().setDistributionSetId(rest
|
||||
.getDsId()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static DistributionSetResource createDistributionSetResource() {
|
||||
final DistributionSetResource distributionSetResource = Feign.builder().logger(new Logger.ErrorLogger())
|
||||
.logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder())
|
||||
.requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin"))
|
||||
.target(DistributionSetResource.class, "http://localhost:8080");
|
||||
return distributionSetResource;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* 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.mgmt.api.client;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.app.Start;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.AssignedTargetRequestBody;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.tag.TargetTagAssigmentResultRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody;
|
||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.context.annotation.Description;
|
||||
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
import feign.Feign;
|
||||
import feign.Logger;
|
||||
import feign.auth.BasicAuthRequestInterceptor;
|
||||
import feign.jackson.JacksonDecoder;
|
||||
import feign.jackson.JacksonEncoder;
|
||||
|
||||
@Features("Example Tests - Management RESTful API Client")
|
||||
@Stories("Target Tag Resource")
|
||||
public class TargetTagTest {
|
||||
|
||||
private TargetTagResource targetTagResource;
|
||||
|
||||
private static List<AssignedTargetRequestBody> assignedTargetRequestBodies;
|
||||
|
||||
@BeforeClass
|
||||
public static void startupServer() {
|
||||
SpringApplication.run(Start.class, new String[0]);
|
||||
createTargetsAssignment();
|
||||
assignedTargetRequestBodies.add(new AssignedTargetRequestBody().setControllerId("NotExist"));
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.targetTagResource = createTargetTagResource();
|
||||
}
|
||||
|
||||
// disabled as this runs not on CI environments.
|
||||
@Test
|
||||
@Description("Simple request of target tag by ID")
|
||||
@Ignore
|
||||
public void getTargetTag() {
|
||||
final TagsRest result = createTargetTags(2);
|
||||
|
||||
assertThat(targetTagResource.getTargetTag(result.get(0).getTagId()).getName()).isEqualTo("Tag0");
|
||||
|
||||
deleteTargets(result);
|
||||
}
|
||||
|
||||
// disabled as this runs not on CI environments.
|
||||
@Test
|
||||
@Description("Simple update of a target tag")
|
||||
@Ignore
|
||||
public void updateTargetTag() {
|
||||
final TagsRest created = createTargetTags(10);
|
||||
|
||||
targetTagResource.updateTagretTag(created.get(0).getTagId(), new TagRequestBodyPut().setDescription("Test")
|
||||
.setName("Test").setColour("Green"));
|
||||
|
||||
final TagRest targetTag = targetTagResource.getTargetTag(created.get(0).getTagId());
|
||||
assertThat(targetTag.getName()).isEqualTo("Test");
|
||||
assertThat(targetTag.getDescription()).isEqualTo("Test");
|
||||
assertThat(targetTag.getColour()).isEqualTo("Green");
|
||||
|
||||
deleteTargets(created);
|
||||
}
|
||||
|
||||
// disabled as this runs not on CI environments.
|
||||
@Test
|
||||
@Description("Simple request of all assigned targets by a target tag.")
|
||||
@Ignore
|
||||
public void getTargetsByTargetTagId() {
|
||||
final TagsRest created = createTargetTags(10);
|
||||
final Long tagId = created.get(2).getTagId();
|
||||
targetTagResource.assignTargets(tagId, assignedTargetRequestBodies);
|
||||
|
||||
final TagRest targetTag = targetTagResource.getTargetTag(tagId);
|
||||
assertThat(targetTagResource.getAssignedTargets(tagId)).hasSize(5);
|
||||
|
||||
targetTagResource.unassignTargets(targetTag.getTagId());
|
||||
deleteTargets(created);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Description("Toggle request to unassigned all assigned targets and assign all unassigned targets.")
|
||||
@Ignore
|
||||
public void toggleTagAssignment() {
|
||||
final TagsRest created = createTargetTags(10);
|
||||
final Long id = created.get(2).getTagId();
|
||||
|
||||
targetTagResource.assignTargets(id, assignedTargetRequestBodies);
|
||||
targetTagResource.unassignTarget(id, assignedTargetRequestBodies.get(0).getControllerId());
|
||||
|
||||
TargetTagAssigmentResultRest assigmentResultRest = targetTagResource.toggleTagAssignment(id,
|
||||
assignedTargetRequestBodies);
|
||||
|
||||
final TagRest targetTag = targetTagResource.getTargetTag(created.get(2).getTagId());
|
||||
assertThat(assigmentResultRest.getAssignedTargets()).hasSize(1);
|
||||
assertThat(assigmentResultRest.getUnassignedTargets()).hasSize(0);
|
||||
|
||||
assigmentResultRest = targetTagResource.toggleTagAssignment(id, assignedTargetRequestBodies);
|
||||
assertThat(assigmentResultRest.getAssignedTargets()).hasSize(0);
|
||||
assertThat(assigmentResultRest.getUnassignedTargets()).hasSize(5);
|
||||
|
||||
targetTagResource.unassignTargets(targetTag.getTagId());
|
||||
deleteTargets(created);
|
||||
}
|
||||
|
||||
private void deleteTargets(final List<TagRest> tags) {
|
||||
for (final TagRest tag : tags) {
|
||||
targetTagResource.deleteTargetTag(tag.getTagId());
|
||||
}
|
||||
}
|
||||
|
||||
private TagsRest createTargetTags(final int number) {
|
||||
|
||||
final List<TagRequestBodyPut> tags = new ArrayList<>();
|
||||
for (int i = 0; i < number; i++) {
|
||||
tags.add(new TagRequestBodyPut().setDescription("Tag " + i).setName("Tag" + i).setColour("Red"));
|
||||
}
|
||||
|
||||
final TagsRest result = targetTagResource.createTargetTag(tags);
|
||||
|
||||
assertThat(result).hasSize(number);
|
||||
return result;
|
||||
}
|
||||
|
||||
private TargetTagResource createTargetTagResource() {
|
||||
final TargetTagResource targetResource = Feign.builder().logger(new Logger.ErrorLogger())
|
||||
.logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder())
|
||||
.requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin"))
|
||||
.target(TargetTagResource.class, "http://localhost:8080");
|
||||
return targetResource;
|
||||
}
|
||||
|
||||
private static void createTargetsAssignment() {
|
||||
|
||||
final List<TargetRequestBody> targets = new ArrayList<>();
|
||||
assignedTargetRequestBodies = new ArrayList<>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
|
||||
targets.add(new TargetRequestBody().setControllerId("test" + i).setName("testDevice"));
|
||||
}
|
||||
|
||||
final TargetsRest result = createTargetResource().createTargets(targets);
|
||||
for (final TargetRest rest : result) {
|
||||
assignedTargetRequestBodies.add(new AssignedTargetRequestBody().setControllerId(rest.getControllerId()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static TargetResource createTargetResource() {
|
||||
final TargetResource targetResource = Feign.builder().logger(new Logger.ErrorLogger())
|
||||
.logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder())
|
||||
.requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin"))
|
||||
.target(TargetResource.class, "http://localhost:8080");
|
||||
return targetResource;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/**
|
||||
* 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.mgmt.api.client;
|
||||
|
||||
import static org.fest.assertions.api.Assertions.assertThat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.app.Start;
|
||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetPagedList;
|
||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody;
|
||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetRest;
|
||||
import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.context.annotation.Description;
|
||||
|
||||
import feign.Feign;
|
||||
import feign.Logger;
|
||||
import feign.auth.BasicAuthRequestInterceptor;
|
||||
import feign.jackson.JacksonDecoder;
|
||||
import feign.jackson.JacksonEncoder;
|
||||
import ru.yandex.qatools.allure.annotations.Features;
|
||||
import ru.yandex.qatools.allure.annotations.Stories;
|
||||
|
||||
@Features("Example Tests - Management RESTful API Client")
|
||||
@Stories("Target Resource")
|
||||
public class TargetTest {
|
||||
|
||||
@BeforeClass
|
||||
public static void startupServer() {
|
||||
SpringApplication.run(Start.class, new String[0]);
|
||||
}
|
||||
|
||||
// disabled as this runs not on CI environments.
|
||||
@Test
|
||||
@Description("Simple request of target by ID")
|
||||
@Ignore
|
||||
public void getTarget() {
|
||||
final TargetResource targetResource = createTargetResource();
|
||||
final TargetsRest result = createTargets(targetResource, 1);
|
||||
|
||||
assertThat(targetResource.getTarget("test0").getName()).isEqualTo("testDevice");
|
||||
|
||||
deleteTargets(targetResource, result);
|
||||
}
|
||||
|
||||
// disabled as this runs not on CI environments.
|
||||
@Test
|
||||
@Description("Simple request of all targets with defined page sizing information (i.e. offset and limit).")
|
||||
@Ignore
|
||||
public void getTargetsAsPagedListWithDefinedPageSizing() {
|
||||
final TargetResource targetResource = createTargetResource();
|
||||
final TargetsRest created = createTargets(targetResource, 20);
|
||||
|
||||
final TargetPagedList queryResult = targetResource.getTargets(0, 10);
|
||||
|
||||
assertThat(queryResult.getContent()).hasSize(10);
|
||||
assertThat(queryResult.getTotal()).isEqualTo(20);
|
||||
assertThat(queryResult.getSize()).isEqualTo(10);
|
||||
|
||||
deleteTargets(targetResource, created);
|
||||
}
|
||||
|
||||
// disabled as this runs not on CI environments.
|
||||
@Test
|
||||
@Description("Simple request of all targets with defualt paging parameters.")
|
||||
@Ignore
|
||||
public void getTargetsAsPagedListWithDefaultPageSizing() {
|
||||
final TargetResource targetResource = createTargetResource();
|
||||
final TargetsRest created = createTargets(targetResource, 20);
|
||||
|
||||
final TargetPagedList queryResult = targetResource.getTargets();
|
||||
|
||||
assertThat(queryResult.getContent()).hasSize(20);
|
||||
assertThat(queryResult.getTotal()).isEqualTo(20);
|
||||
assertThat(queryResult.getSize()).isEqualTo(20);
|
||||
|
||||
deleteTargets(targetResource, created);
|
||||
}
|
||||
|
||||
private void deleteTargets(final TargetResource targetResource, final List<TargetRest> targets) {
|
||||
for (final TargetRest targetRest : targets) {
|
||||
targetResource.deleteTarget(targetRest.getControllerId());
|
||||
}
|
||||
}
|
||||
|
||||
private TargetsRest createTargets(final TargetResource targetResource, final int number) {
|
||||
|
||||
final List<TargetRequestBody> targets = new ArrayList<>();
|
||||
for (int i = 0; i < number; i++) {
|
||||
|
||||
targets.add(new TargetRequestBody().setControllerId("test" + i).setName("testDevice"));
|
||||
}
|
||||
|
||||
final TargetsRest result = targetResource.createTargets(targets);
|
||||
|
||||
assertThat(result).hasSize(number);
|
||||
return result;
|
||||
}
|
||||
|
||||
private TargetResource createTargetResource() {
|
||||
final TargetResource targetResource = Feign.builder().logger(new Logger.ErrorLogger())
|
||||
.logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder())
|
||||
.requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin"))
|
||||
.target(TargetResource.class, "http://localhost:8080");
|
||||
return targetResource;
|
||||
}
|
||||
|
||||
}
|
||||
1
examples/pom.xml
Executable file → Normal file
1
examples/pom.xml
Executable file → Normal file
@@ -25,6 +25,7 @@
|
||||
<modules>
|
||||
<module>hawkbit-device-simulator</module>
|
||||
<module>hawkbit-example-app</module>
|
||||
<module>hawkbit-mgmt-api-client</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
Reference in New Issue
Block a user