Skip to content

Commit

Permalink
REST Implementation for SystemInfo
Browse files Browse the repository at this point in the history
Delete SystemInfomationResource1_8.java

SystemInfo REST Implementation

REST Implementation for SystemInfo

Delete SystemInfomationResource1_8.java

SystemInfo REST - Comments removal
  • Loading branch information
suthagar23 committed Jun 26, 2017
1 parent 67deaa3 commit 59c1bee
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
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";
}
}
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);

}
}

0 comments on commit 59c1bee

Please sign in to comment.