Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions buildSrc/src/main/groovy/TestSummaryListener.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,47 @@ import org.gradle.api.tasks.testing.TestResult

class TestSummaryListener implements TestListener, Serializable {

private final List<String> failedTests = Collections.synchronizedList(new ArrayList<>())
private final List<String> failedTests = Collections.synchronizedList(new ArrayList<>())

@Override
void beforeSuite(TestDescriptor suite) {}
@Override
void beforeSuite(TestDescriptor suite) {}

@Override
void afterSuite(TestDescriptor desc, TestResult result) {
if (desc.parent != null) {
return
}
@Override
void afterSuite(TestDescriptor desc, TestResult result) {
if (desc.parent != null) {
return
}

def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
def startItem = '| '
def endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
def startItem = '| '
def endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()

println '\n' +
('-' * repeatLength) + '\n' +
startItem + output + endItem + '\n' +
('-' * repeatLength)
println '\n' +
('-' * repeatLength) + '\n' +
startItem + output + endItem + '\n' +
('-' * repeatLength)

def failures = new ArrayList<>(failedTests).sort()
def failures = new ArrayList<>(failedTests).sort()

if (!failures.empty) {
println '\nFailed tests:'
failures.each { failure ->
println " - ${failure}"
}
}
if (!failures.empty) {
println '\nFailed tests:'
failures.each { failure ->
println " - ${failure}"
}
}
}

@Override
void beforeTest(TestDescriptor desc) {}

@Override
void afterTest(TestDescriptor desc, TestResult result) {
if (result.resultType == TestResult.ResultType.FAILURE) {
def className = desc.className ?: desc.parent?.name ?: '<unknown>'
failedTests.add("${className} > ${desc.name}")
}
@Override
void beforeTest(TestDescriptor desc) {}

println "${desc.className} > ${desc.name} took: ${(result.endTime - result.startTime)}ms"
@Override
void afterTest(TestDescriptor desc, TestResult result) {
if (result.resultType == TestResult.ResultType.FAILURE) {
def className = desc.className ?: desc.parent?.name ?: '<unknown>'
failedTests.add("${className} > ${desc.name}")
}

println "${desc.className} > ${desc.name} took: ${(result.endTime - result.startTime)}ms"
}
}
3 changes: 2 additions & 1 deletion spotless.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ spotless {
endWithNewline()
}

// Groovy files are not yet formatted because some use '::' operations which greclipse currently cannot handle
groovy {
target backendTarget(['**/*.groovy'])
toggleOffOn()
greclipse().configFile(rootProject.file('tools/spotless/greclipse-google.properties'))
licenseHeaderFile(rootProject.file('tools/spotless/openremote-license-header.txt'), blockCommentLicenseDelimiter)
trimTrailingWhitespace()
endWithNewline()
Expand Down
42 changes: 21 additions & 21 deletions test/src/test/groovy/org/openremote/test/custom/CustomTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,34 @@ import spock.util.concurrent.PollingConditions

class CustomTest extends Specification implements ManagerContainerTrait {

def "Check custom agent and protocol"() {
def "Check custom agent and protocol"() {

given: "expected conditions"
def conditions = new PollingConditions(timeout: 10, delay: 1)
given: "expected conditions"
def conditions = new PollingConditions(timeout: 10, delay: 1)

when: "the container starts"
def serverPort = findEphemeralPort()
def container = startContainer(defaultConfig(serverPort), defaultServices())
def assetStorageService = container.getService(AssetStorageService.class)
def agentService = container.getService(AgentService.class)
when: "the container starts"
def serverPort = findEphemeralPort()
def container = startContainer(defaultConfig(serverPort), defaultServices())
def assetStorageService = container.getService(AssetStorageService.class)
def agentService = container.getService(AgentService.class)

then: "the container should be running"
conditions.eventually {
assert container.isRunning()
}
then: "the container should be running"
conditions.eventually {
assert container.isRunning()
}

when: "a custom agent asset is added"
def agent = new CustomAgent("Test Agent")
when: "a custom agent asset is added"
def agent = new CustomAgent("Test Agent")
.setRealm(Constants.MASTER_REALM)
.setOption(CustomAgent.Option.TWO)

and: "the agent is added to the asset service"
agent = assetStorageService.merge(agent)
and: "the agent is added to the asset service"
agent = assetStorageService.merge(agent)

then: "the agent should be started"
conditions.eventually {
assert agentService.protocolInstanceMap.get(agent.id) != null
assert (agentService.protocolInstanceMap.get(agent.id) as CustomProtocol).running
}
then: "the agent should be started"
conditions.eventually {
assert agentService.protocolInstanceMap.get(agent.id) != null
assert (agentService.protocolInstanceMap.get(agent.id) as CustomProtocol).running
}
}
}
Loading