-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete SystemInfomationResource1_8.java SystemInfo REST Implementation REST Implementation for SystemInfo Delete SystemInfomationResource1_8.java SystemInfo REST - Comments removal
- Loading branch information
1 parent
67deaa3
commit 59c1bee
Showing
2 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...rs/module/webservices/rest/web/v1_0/resource/openmrs1_8/SystemInformationResource1_8.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; | ||
|
||
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.web.ConversionUtil; | ||
import org.openmrs.module.webservices.rest.web.RequestContext; | ||
import org.openmrs.module.webservices.rest.web.RestConstants; | ||
import org.openmrs.module.webservices.rest.web.annotation.Resource; | ||
import org.openmrs.module.webservices.rest.web.resource.api.Listable; | ||
import org.openmrs.module.webservices.rest.web.response.ResponseException; | ||
|
||
// the framework requires we specify a supportedClass, even though this shouldn't have one | ||
@Resource(name = RestConstants.VERSION_1 + "/systeminformation", supportedClass = AdministrationServiceImpl.class, supportedOpenmrsVersions = { | ||
"1.10.*", "1.11.*", "1.12.*", "1.8.*", "1.9.*", "2.0.*", "2.1.*" }) | ||
public class SystemInformationResource1_8 implements Listable { | ||
|
||
@Override | ||
public SimpleObject getAll(RequestContext context) throws ResponseException { | ||
SimpleObject rest = new SimpleObject(); | ||
try { | ||
//Push System informations to rest object with Key as SystemInfo | ||
rest.put("SystemInfo", Context.getAdministrationService().getSystemInformation()); | ||
} | ||
catch (Exception ex) { | ||
System.out.println("SystemInfo Resource is getting Error"); | ||
} | ||
return rest; | ||
} | ||
|
||
@Override | ||
public String getUri(Object instance) { | ||
return RestConstants.URI_PREFIX + "/systeminformation"; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...odule/webservices/rest/web/v1_0/resource/openmrs1_8/SystemInformationResource1_8Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, | ||
* v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
* obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under | ||
* the terms of the Healthcare Disclaimer located at http://openmrs.org/license. | ||
* | ||
* Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS | ||
* graphic logo is a trademark of OpenMRS Inc. | ||
*/ | ||
package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; | ||
|
||
import java.util.List; | ||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
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.Before; | ||
//import org.junit.Ignore; | ||
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; | ||
|
||
public class SystemInformationResource1_8Test extends BaseModuleWebContextSensitiveTest { | ||
|
||
@Autowired | ||
private MainResourceController mainResourceController; | ||
|
||
@Test | ||
public void testGetAll() throws Exception { | ||
SimpleObject rest = new SimpleObject(); | ||
rest.put("SystemInfo", Context.getAdministrationService().getSystemInformation()); | ||
|
||
// Retrive the System Information using HTTP GET Request | ||
MockHttpServletResponse response = new MockHttpServletResponse(); | ||
SimpleObject config = mainResourceController.get("systeminformation", new MockHttpServletRequest(), response); | ||
|
||
Assert.assertEquals(config, rest); | ||
|
||
} | ||
} |