Skip to content

Commit

Permalink
SystemInformation REST updates
Browse files Browse the repository at this point in the history
  • Loading branch information
suthagar23 committed Jul 24, 2017
1 parent b2cbf90 commit eb0565b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,9 @@ public class SystemInformationResource1_8 implements Listable {
@Override
public SimpleObject getAll(RequestContext context) throws ResponseException {
SimpleObject rest = new SimpleObject();
try {
rest.put("SystemInfo", Context.getAdministrationService().getSystemInformation());
}
catch (Exception ex) {
System.out.println(ex.getMessage());
}
finally {
return rest;
}
rest.put("SystemInfo", Context.getAdministrationService().getSystemInformation());
return rest;

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,79 @@
*/
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8;

import static org.junit.Assert.assertEquals;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.mock.MockHttpServletRequest;

import org.apache.struts.mock.MockHttpServletResponse;
import org.apache.commons.beanutils.PropertyUtils;
import org.junit.Assert;
import org.junit.Test;
import org.openmrs.api.impl.AdministrationServiceImpl;
import org.openmrs.api.context.Context;
import org.openmrs.module.webservices.rest.SimpleObject;
import org.openmrs.module.webservices.rest.test.Util;
import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController;
import org.springframework.beans.factory.annotation.Autowired;
import org.openmrs.web.test.BaseModuleWebContextSensitiveTest;
import org.openmrs.api.AdministrationService;
import java.util.Map;
import org.springframework.mock.web.MockHttpServletRequest;

public class SystemInformationResource1_8Test extends BaseModuleWebContextSensitiveTest {

private AdministrationService administrationService;

@Autowired
private MainResourceController mainResourceController;

public String getURI() {
return "systeminformation";
}

@Test
public void testGetAll() throws Exception {
SimpleObject rest = new SimpleObject();
rest.put("SystemInfo", Context.getAdministrationService().getSystemInformation());

MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("GET");
MockHttpServletResponse response = new MockHttpServletResponse();
SimpleObject config = mainResourceController.get("systeminformation", new MockHttpServletRequest(), response);
Assert.assertEquals(config, rest);
SimpleObject result = mainResourceController.get(getURI(), request, response);

Map<String, Map<String, String>> systemInfo = result.get("SystemInfo");

// Check openmrsInformation
Map<String, String> openmrsInformation = systemInfo.get("SystemInfo.title.openmrsInformation");
Assert.assertTrue(systemInfo.containsKey("SystemInfo.title.openmrsInformation"));
// Check openmrsInformation Property
Assert.assertTrue(openmrsInformation.containsKey("SystemInfo.OpenMRSInstallation.systemDate"));
Assert.assertTrue(openmrsInformation.containsKey("SystemInfo.OpenMRSInstallation.systemTime"));
Assert.assertTrue(openmrsInformation.containsKey("SystemInfo.OpenMRSInstallation.openmrsVersion"));

// Check javaRuntimeEnvironmentInformation
Map<String, String> javRuntime = systemInfo.get("SystemInfo.title.javaRuntimeEnvironmentInformation");
Assert.assertTrue(systemInfo.containsKey("SystemInfo.title.javaRuntimeEnvironmentInformation"));
// Check javaRuntimeEnvironmentInformation Property
Assert.assertTrue(javRuntime.containsKey("SystemInfo.JavaRuntimeEnv.operatingSystem"));
Assert.assertTrue(javRuntime.containsKey("SystemInfo.JavaRuntimeEnv.operatingSystemArch"));
Assert.assertTrue(javRuntime.containsKey("SystemInfo.JavaRuntimeEnv.operatingSystemVersion"));
Assert.assertTrue(javRuntime.containsKey("SystemInfo.JavaRuntimeEnv.javaVersion"));
Assert.assertTrue(javRuntime.containsKey("SystemInfo.JavaRuntimeEnv.javaVendor"));

// Check memoryInformation
Map<String, String> memoryInformation = systemInfo.get("SystemInfo.title.memoryInformation");
Assert.assertTrue(systemInfo.containsKey("SystemInfo.title.memoryInformation"));
// Check memoryInformation Property
Assert.assertTrue(memoryInformation.containsKey("SystemInfo.Memory.totalMemory"));
Assert.assertTrue(memoryInformation.containsKey("SystemInfo.Memory.freeMemory"));
Assert.assertTrue(memoryInformation.containsKey("SystemInfo.Memory.maximumHeapSize"));

// Check dataBaseInformation
Map<String, String> dataBaseInformation = systemInfo.get("SystemInfo.title.dataBaseInformation");
Assert.assertTrue(systemInfo.containsKey("SystemInfo.title.dataBaseInformation"));
// Check dataBaseInformation Property
Assert.assertTrue(dataBaseInformation.containsKey("SystemInfo.Database.name"));
Assert.assertTrue(dataBaseInformation.containsKey("SystemInfo.Database.connectionURL"));
Assert.assertTrue(dataBaseInformation.containsKey("SystemInfo.Database.userName"));
Assert.assertTrue(dataBaseInformation.containsKey("SystemInfo.Database.driver"));
Assert.assertTrue(dataBaseInformation.containsKey("SystemInfo.Database.dialect"));

// Check moduleInformation
Map<String, String> moduleInformation = systemInfo.get("SystemInfo.title.moduleInformation");
Assert.assertTrue(systemInfo.containsKey("SystemInfo.title.moduleInformation"));
// Check moduleInformation Property
Assert.assertTrue(moduleInformation.containsKey("SystemInfo.Module.repositoryPath"));
}
}

0 comments on commit eb0565b

Please sign in to comment.