Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
dima767 committed Jan 15, 2020
1 parent 8453a69 commit c895f19
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/
public class DefaultBeaconPublisher implements BeaconPublisher {

private URL enpointUrl;
private URL endpointUrl;

private String jsonPayload;

Expand All @@ -42,7 +42,7 @@ public DefaultBeaconPublisher(Map<String, String> beaconDetails) {
throw new IllegalArgumentException("Not all the necessary beacon data is available to be able to publish to beacon");
}
try {
this.enpointUrl = new URL(String.format("http://%s:%s", beaconDetails.get(LOG_HOST), beaconDetails.get(LOG_PORT)));
this.endpointUrl = new URL(String.format("http://%s:%s", beaconDetails.get(LOG_HOST), beaconDetails.get(LOG_PORT)));
} catch (MalformedURLException ex) {
throw new IllegalArgumentException(ex.getMessage());
}
Expand All @@ -65,7 +65,7 @@ public DefaultBeaconPublisher(Map<String, String> beaconDetails) {
@Override
public void run() {
try {
HttpURLConnection con = (HttpURLConnection) this.enpointUrl.openConnection();
HttpURLConnection con = (HttpURLConnection) this.endpointUrl.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json; utf-8");
con.setRequestProperty("Accept", "application/json");
Expand All @@ -77,13 +77,11 @@ public void run() {
} catch (IOException e) {
e.printStackTrace();
}


}

//getters used in unit tests and calling components for debugging purposes
public String getEndpointUri() {
return enpointUrl.toString();
return endpointUrl.toString();
}

public String getJsonPayload() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ public class DefaultBeaconPublisherTests {

@Test
public void checkCorrectInvariantsWithBeaconDataNull() {
assertThrows(IllegalArgumentException.class, () -> {
new DefaultBeaconPublisher(null);
});
assertThrows(IllegalArgumentException.class, () -> new DefaultBeaconPublisher(null));
}

@Test
public void checkCorrectInvariantsWithBeaconDataEmpty() {
assertThrows(IllegalArgumentException.class, () -> {
new DefaultBeaconPublisher(new HashMap<>());
});
assertThrows(IllegalArgumentException.class, () -> new DefaultBeaconPublisher(new HashMap<>()));
}

@Test
Expand Down

0 comments on commit c895f19

Please sign in to comment.