Skip to content

Commit

Permalink
Address code review
Browse files Browse the repository at this point in the history
  • Loading branch information
dima767 committed Jan 21, 2020
1 parent e403ef6 commit 70dc84c
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 44 deletions.
23 changes: 20 additions & 3 deletions beacon/core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
apply plugin: 'java'
import org.springframework.boot.gradle.plugin.SpringBootPlugin

plugins {
id 'org.springframework.boot' version '2.0.0.RELEASE' apply false
id 'io.spring.dependency-management' version '1.0.6.RELEASE'
}

apply plugin: 'groovy'
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
jcenter()
}

dependencyManagement {
imports {
mavenBom SpringBootPlugin.BOM_COORDINATES
}
}

dependencies {
testCompile "org.springframework.boot:spring-boot-starter-test"
testCompile "org.spockframework:spock-core:1.1-groovy-2.4"
testCompile "org.spockframework:spock-spring:1.1-groovy-2.4"

testCompile 'org.junit.jupiter:junit-jupiter-api:5.5.2'
testCompile 'org.junit.jupiter:junit-jupiter-engine:5.5.2'
}
Expand All @@ -15,6 +32,6 @@ jar {
archiveName = "beacon-core-${version}.jar"
}

test {
/*test {
useJUnitPlatform()
}
}*/
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
*/
public class DefaultBeaconPublisher implements BeaconPublisher {

private URL endpointUrl;
private final URL endpointUrl;

private String jsonPayload;
private final String jsonPayload;

public DefaultBeaconPublisher(Map<String, String> beaconDetails) {
//Do data validation checks here. If any of the necessary beacon data not available here, throw a Runtime exception
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package edu.internet2.tap.beacon

import spock.lang.Specification
import sun.security.x509.OtherName

class DefaultBeaconPublisherTests extends Specification {

def "DefaultBeaconPublisher invariants are enforced during object creation - null Map is passed"() {
when:
new DefaultBeaconPublisher(null)

then:
thrown IllegalArgumentException

}

def "DefaultBeaconPublisher invariants are enforced during object creation - empty Map is passed"() {
when:
new DefaultBeaconPublisher([:])

then:
thrown IllegalArgumentException
}

def "DefaultBeaconPublisher invariants are enforced during object creation - valid Beacon data Map is passed"() {
when:
def expectedJsonPaylaod = """{"msgType":"TIERBEACON", "tbMaintainer":"unittest_maintainer", "msgName":"TIER", "tbProduct":"image", "msgVersion":"1.0", "tbProductVersion":"v1", "tbTIERRelease":"tv1"}"""

def configuredBeaconData = [LOGHOST : 'collector.testbed.tier.internet2.edu',
LOGPORT : '5001',
IMAGE : 'image',
VERSION : 'v1',
TIERVERSION: 'tv1',
MAINTAINER : 'unittest_maintainer']
def p = new DefaultBeaconPublisher(configuredBeaconData)
println p.jsonPayload

then:
noExceptionThrown()
p.endpointUri == 'http://collector.testbed.tier.internet2.edu:5001'
p.jsonPayload == expectedJsonPaylaod

}

}

This file was deleted.

0 comments on commit 70dc84c

Please sign in to comment.