Skip to content

Commit

Permalink
#9 address some sonar issue in wilma-service-api (preparing the relea…
Browse files Browse the repository at this point in the history
…se of the module)
  • Loading branch information
tkohegyi committed Jul 24, 2015
1 parent 7bc278d commit 3eb1341
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
public class WilmaApplication {
private static final Logger LOG = LoggerFactory.getLogger(WilmaApplication.class);

private static final JSONObject EMPTY_JSON = new JSONObject();

private static final String VERSION_INFO_URL_POSTFIX = "config/public/version";
private static final String ACTUAL_LOAD_INFO_URL_POSTFIX = "config/public/actualload";
private static final String SHUTDOWN_URL_POSTFIX = "config/admin/shutdown";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public MessageLoggingControlStatus getMessageLoggingStatus() {
Boolean requestLogging = (Boolean) o.get("requestLogging");
Boolean responseLogging = (Boolean) o.get("responseLogging");

if (requestLogging & responseLogging) {
if (requestLogging && responseLogging) {
status = MessageLoggingControlStatus.ON;
} else {
status = MessageLoggingControlStatus.OFF;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,20 @@ public WilmaLoadInformation(final JSONObject jsonObject) {
loggerQueueSize = (Integer) jsonObject.get("loggerQueueSize");
}

public Integer getDeletedFilesCount() { return deletedFilesCount; }
public Integer getCountOfMessages() { return countOfMessages; }
public Integer getResponseQueueSize() { return responseQueueSize; }
public Integer getLoggerQueueSize() { return loggerQueueSize; }
public Integer getDeletedFilesCount() {
return deletedFilesCount;
}

public Integer getCountOfMessages() {
return countOfMessages;
}

public Integer getResponseQueueSize() {
return responseQueueSize;
}

public Integer getLoggerQueueSize() {
return loggerQueueSize;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ public class OperationConfigurationTest {
private static final String OPERATION_MODE_SETTER_URL_WILMA = "http://host:1/config/admin/switch/wilma";
private static final String OPERATION_MODE_SETTER_URL_STUB = "http://host:1/config/admin/switch/stub";
private static final String OPERATION_MODE_SETTER_URL_PROXY = "http://host:1/config/admin/switch/proxy";
private static final String JSON_STRING = "{\"proxyMode\":false,\"stubMode\":false,\"wilmaMode\":true}";
private static final String JSON_STRING_WILMA_MODE = "{\"proxyMode\":false,\"stubMode\":false,\"wilmaMode\":true}";
private static final String JSON_STRING_STUB_MODE = "{\"proxyMode\":false,\"stubMode\":true,\"wilmaMode\":false}";
private static final String JSON_STRING_PROXY_MODE = "{\"proxyMode\":true,\"stubMode\":false,\"wilmaMode\":false}";

@Mock
private WilmaHttpClient client;
Expand Down Expand Up @@ -84,12 +86,32 @@ public void shouldReturnNullIfClientReturnsOptionalAbsent() {
}

@Test
public void shouldReturnWithProperValue() {
when(client.sendGetterRequest(OPERATION_MODE_STATUS_URL)).thenReturn(Optional.of(JSON_STRING));
public void shouldReturnWithProperValueWilma() {
when(client.sendGetterRequest(OPERATION_MODE_STATUS_URL)).thenReturn(Optional.of(JSON_STRING_WILMA_MODE));

OperationMode result = operationConfiguration.getOperationMode();

assertTrue(result == OperationMode.WILMA, "The two JSON objects should be similar.");
assertTrue(result == OperationMode.WILMA, "The operation mode should be WILMA.");
verify(client, never()).sendSetterRequest(anyString());
}

@Test
public void shouldReturnWithProperValueStub() {
when(client.sendGetterRequest(OPERATION_MODE_STATUS_URL)).thenReturn(Optional.of(JSON_STRING_STUB_MODE));

OperationMode result = operationConfiguration.getOperationMode();

assertTrue(result == OperationMode.STUB, "The operation mode should be STUB.");
verify(client, never()).sendSetterRequest(anyString());
}

@Test
public void shouldReturnWithProperValueProxy() {
when(client.sendGetterRequest(OPERATION_MODE_STATUS_URL)).thenReturn(Optional.of(JSON_STRING_PROXY_MODE));

OperationMode result = operationConfiguration.getOperationMode();

assertTrue(result == OperationMode.PROXY, "The operation mode should be PROXY.");
verify(client, never()).sendSetterRequest(anyString());
}

Expand Down

0 comments on commit 3eb1341

Please sign in to comment.