Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Enable Spotless formatting for Groovy files

Wouter Born5312a1199b0e
diff --git a/spotless.gradle b/spotless.gradle
index 905af8b87..a2d4cff3a 100644
--- a/spotless.gradle
+++ b/spotless.gradle
@@ -96,9 +96,11 @@ spotless {
endWithNewline()
}
- // Groovy files are not yet formatted because some use '::' operations which greclipse currently cannot handle
groovy {
target backendTarget(['**/*.groovy'])
+ targetExclude('**/BasicBrokenRules.groovy')
+ toggleOffOn()
+ greclipse().configFile(rootProject.file('tools/spotless/greclipse-google.properties'))
licenseHeaderFile(rootProject.file('tools/spotless/openremote-license-header.txt'), blockCommentLicenseDelimiter)
trimTrailingWhitespace()
endWithNewline()
diff --git a/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy b/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
index 770f83711..3441db48f 100644
--- a/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/console/ConsoleTest.groovy
@@ -410,9 +410,8 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
"Test Console",
"1.0",
"Android 7.0",
- new HashMap<String, ConsoleProvider>() {
- {
- put("geofence", new ConsoleProvider(
+ new HashMap<String, ConsoleProvider>(
+ geofence: new ConsoleProvider(
ORConsoleGeofenceAssetAdapter.NAME,
true,
false,
@@ -420,8 +419,8 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
false,
false,
null
- ))
- put("push", new ConsoleProvider(
+ ),
+ push: new ConsoleProvider(
"fcm",
true,
true,
@@ -429,9 +428,8 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
true,
false,
(Map)parse("{\"token\": \"23123213ad2313b0897efd\"}").orElse(null)
- ))
- }
- },
+ )
+ ),
"",
["manager"] as String[])
def returnedConsoleRegistration = authenticatedConsoleResource.register(null, consoleRegistration)
@@ -1030,9 +1028,8 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
name,
"1.0",
"Android 7.0",
- new HashMap<String, ConsoleProvider>() {
- {
- put("push", new ConsoleProvider(
+ new HashMap<String, ConsoleProvider>(
+ push: new ConsoleProvider(
"fcm",
true,
true,
@@ -1040,9 +1037,8 @@ class ConsoleTest extends Specification implements ManagerContainerTrait {
true,
false,
[token: pushToken]
- ))
- }
- },
+ )
+ ),
"",
["manager"] as String[]
)
diff --git a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
index a18805b62..8532bb57f 100644
--- a/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/notification/NotificationTest.groovy
@@ -162,9 +162,8 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
"Test Console",
"1.0",
"Android 7.0",
- new HashMap<String, ConsoleProvider>() {
- {
- put("geofence", new ConsoleProvider(
+ new HashMap<String, ConsoleProvider>(
+ geofence: new ConsoleProvider(
ORConsoleGeofenceAssetAdapter.NAME,
true,
false,
@@ -172,8 +171,8 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
false,
false,
null
- ))
- put("push", new ConsoleProvider(
+ ),
+ push: new ConsoleProvider(
"fcm",
true,
true,
@@ -181,9 +180,8 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
true,
false,
(Map) parse("{\"token\": \"23123213ad2313b0897efd\"}").orElse(null)
- ))
- }
- },
+ )
+ ),
"",
["manager"] as String[])
def testuser2Console = testuser2ConsoleResource.register(null, consoleRegistration)
@@ -809,10 +807,10 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
"MultiLanguageAction",
new LocalizedNotificationMessage(
"en",
- new HashMap<String, AbstractNotificationMessage>() {{
- put("nl", new PushNotificationMessage("Nederlandse titel", "Nederlandse body", null, null, null))
- put("en", new PushNotificationMessage("English title", "English body", null, null, null))
- }}
+ new HashMap<String, AbstractNotificationMessage>(
+ nl: new PushNotificationMessage("Nederlandse titel", "Nederlandse body", null, null, null),
+ en: new PushNotificationMessage("English title", "English body", null, null, null)
+ )
),
null,
null,
@@ -827,9 +825,8 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
"Admin Console",
"1.0",
"Android 7.0",
- new HashMap<String, ConsoleProvider>() {
- {
- put("geofence", new ConsoleProvider(
+ new HashMap<String, ConsoleProvider>(
+ geofence: new ConsoleProvider(
ORConsoleGeofenceAssetAdapter.NAME,
true,
false,
@@ -837,8 +834,8 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
false,
false,
null
- ))
- put("push", new ConsoleProvider(
+ ),
+ push: new ConsoleProvider(
"fcm",
true,
true,
@@ -846,9 +843,8 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
true,
false,
(Map) parse("{\"token\": \"23123213ad2313b0897efd\"}").orElse(null)
- ))
- }
- },
+ )
+ ),
"",
["manager"] as String[])
def adminConsole = adminConsoleResource.register(null, consoleRegistration)
@@ -913,9 +909,8 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
"Test user 1 Console",
"1.0",
"Android 7.0",
- new HashMap<String, ConsoleProvider>() {
- {
- put("geofence", new ConsoleProvider(
+ new HashMap<String, ConsoleProvider>(
+ geofence: new ConsoleProvider(
ORConsoleGeofenceAssetAdapter.NAME,
true,
false,
@@ -923,8 +918,8 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
false,
false,
null
- ))
- put("push", new ConsoleProvider(
+ ),
+ push: new ConsoleProvider(
"fcm",
true,
true,
@@ -932,9 +927,8 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
true,
false,
(Map) parse("{\"token\": \"23123213ad2313b0897efd\"}").orElse(null)
- ))
- }
- },
+ )
+ ),
"",
["manager"] as String[])
def testuser1Console = testuser1ConsoleResource.register(null, testuser1ConsoleRegistration)
@@ -1003,10 +997,10 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
"MultiTypeAction",
new LocalizedNotificationMessage(
"en",
- new HashMap<String, AbstractNotificationMessage>() {{
- put("en", new PushNotificationMessage("English title", "English body", null, null, null))
- put("nl", new EmailNotificationMessage().setSubject("Nederlandse titel").setText("Nederlandse tekst"))
- }}
+ new HashMap<String, AbstractNotificationMessage>(
+ en: new PushNotificationMessage("English title", "English body", null, null, null),
+ nl: new EmailNotificationMessage().setSubject("Nederlandse titel").setText("Nederlandse tekst")
+ )
),
null,
null,
@@ -1067,10 +1061,10 @@ class NotificationTest extends Specification implements ManagerContainerTrait {
"InvalidNotification",
new LocalizedNotificationMessage(
"en",
- new HashMap<String, AbstractNotificationMessage>() {{
- put("nl", new PushNotificationMessage())
- put("en", new PushNotificationMessage("English title", "English body", null, null, null))
- }}
+ new HashMap<String, AbstractNotificationMessage>(
+ nl: new PushNotificationMessage(),
+ en: new PushNotificationMessage("English title", "English body", null, null, null)
+ )
),
null,
null,
diff --git a/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy b/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
index 7b446fe9f..197a14b6a 100644
--- a/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/protocol/KNXProtocolTest.groovy
@@ -96,8 +96,11 @@ class KNXProtocolTest extends Specification implements ManagerContainerTrait {
// inet 127.51.68.120 netmask 0xff000000
// nd6 options=201<PERFORMNUD,DAD>
// Use the same code as Calimero uses to find the address to listen on
- def loopbackIP = ni.inetAddresses().filter(Inet4Address.class::isInstance).findFirst()
- .map((ia) -> ia.getHostAddress()).orElse("127.0.0.1")
+ def loopbackIP = ni.inetAddresses()
+ .filter { it instanceof Inet4Address }
+ .findFirst()
+ .map { it.hostAddress }
+ .orElse("127.0.0.1")
def knxAgent1 = new KNXAgent("KNX Agent 1")
.setHost(loopbackIP)
.setBindHost(loopbackIP)
diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy
index 258f1152d..1912fad2d 100644
--- a/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/residence/JsonRulesTest.groovy
@@ -243,9 +243,8 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
"Test Console",
"1.0",
"Android 7.0",
- new HashMap<String, ConsoleProvider>() {
- {
- put("geofence", new ConsoleProvider(
+ new HashMap<String, ConsoleProvider>(
+ geofence: new ConsoleProvider(
ORConsoleGeofenceAssetAdapter.NAME,
true,
false,
@@ -253,8 +252,8 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
false,
false,
null
- ))
- put("push", new ConsoleProvider(
+ ),
+ push: new ConsoleProvider(
"fcm",
true,
true,
@@ -262,9 +261,8 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
true,
false,
(Map<String, Object>)(parse("{\"token\": \"23123213ad2313b0897efd\"}").orElse(null)
- )))
- }
- },
+ ))
+ ),
"",
["manager"] as String[])
consoleRegistration = authenticatedConsoleResource.register(null, consoleRegistration)
@@ -275,9 +273,8 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
"Test Console",
"1.0",
"Android 7.0",
- new HashMap<String, ConsoleProvider>() {
- {
- put("geofence", new ConsoleProvider(
+ new HashMap<String, ConsoleProvider>(
+ geofence: new ConsoleProvider(
ORConsoleGeofenceAssetAdapter.NAME,
true,
false,
@@ -285,8 +282,8 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
false,
false,
null
- ))
- put("push", new ConsoleProvider(
+ ),
+ push: new ConsoleProvider(
"fcm",
true,
true,
@@ -294,9 +291,8 @@ class JsonRulesTest extends Specification implements ManagerContainerTrait {
true,
false,
(Map<String, Object>)(parse("{\"token\": \"23123213ad2313b0897efd\"}").orElse(null)
- )))
- }
- },
+ ))
+ ),
"",
["manager"] as String[])
consoleRegistration2 = authenticatedConsoleResource2.register(null, consoleRegistration2)
diff --git a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovy b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovy
index 937c3f91e..016513088 100644
--- a/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovy
+++ b/test/src/test/groovy/org/openremote/test/rules/residence/ResidenceNotifyAlarmTriggerTest.groovy
@@ -157,9 +157,8 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
"Test Console",
"1.0",
"Android 7.0",
- new HashMap<String, ConsoleProvider>() {
- {
- put("geofence", new ConsoleProvider(
+ new HashMap<String, ConsoleProvider>(
+ geofence: new ConsoleProvider(
ORConsoleGeofenceAssetAdapter.NAME,
true,
false,
@@ -167,8 +166,8 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
false,
false,
null
- ))
- put("push", new ConsoleProvider(
+ ),
+ push: new ConsoleProvider(
"fcm",
true,
true,
@@ -176,9 +175,8 @@ class ResidenceNotifyAlarmTriggerTest extends Specification implements ManagerCo
true,
false,
((Map) parse("{\"token\": \"23123213ad2313b0897efd\"}").orElse(null)
- )))
- }
- },
+ ))
+ ),
"",
["manager"] as String[])
def returnedConsoleRegistration = authenticatedConsoleResource.register(null, consoleRegistration)