View Javadoc

1   /*
2    * Copyright 2011 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  package org.kuali.mobility.maps.service;
16  
17  import static org.junit.Assert.assertFalse;
18  import static org.junit.Assert.assertTrue;
19  
20  import org.apache.log4j.Logger;
21  import org.junit.AfterClass;
22  import org.junit.Before;
23  import org.junit.BeforeClass;
24  import org.junit.Test;
25  import org.junit.runner.RunWith;
26  import org.kuali.mobility.configparams.service.ConfigParamService;
27  import org.kuali.mobility.maps.entity.Location;
28  import org.kuali.mobility.maps.entity.MapsGroup;
29  import org.mockito.Mock;
30  import org.springframework.http.HttpStatus;
31  import org.springframework.http.ResponseEntity;
32  
33  import static org.mockito.Matchers.any;
34  import static org.mockito.Mockito.when;
35  
36  /**
37   * Implementation of the CXF Device Service
38   * 
39   * @author Kuali Mobility Team (mobility.dev@kuali.org)
40   * @since 3.0
41   */
42  @RunWith(org.mockito.runners.MockitoJUnitRunner.class)
43  public class CXFMapsServiceTest {
44  	private static final Logger LOG = Logger.getLogger(CXFMapsServiceTest.class);
45  	
46  	private CXFMapsService cxfService;
47  	
48  	@Mock
49  	private MapsService service;
50  	@Mock
51  	private ConfigParamService configParamService;
52  	
53  	@Before
54      public void setUpClass() throws Exception {
55  		setCxfService(new CXFMapsService());
56  		getCxfService().setService(getService());
57  		getCxfService().setConfigParamService(getConfigParamService());
58      }
59  
60      @AfterClass
61      public static void tearDownClass() throws Exception {
62      }
63      
64      @Test
65      public void testGetBuildings() {
66      	MapsGroup testGroup = new MapsGroup();
67      	testGroup.setName("testGroup");
68      	when(service.getMapsGroupById(any(String.class))).thenReturn(null).thenReturn(testGroup);
69      	Object object = getCxfService().getBuildings(null);
70      	Object test = new ResponseEntity<String>(HttpStatus.NOT_FOUND).toString();
71      	assertTrue("Should have returned 404", object.toString().equals(test.toString()));
72      	object = getCxfService().getBuildings("1");
73  		assertTrue("returned object does not match test object", object.equals(testGroup.toJson()));
74      }
75      
76      @Test
77      public void testGet() {
78      	Location location = new Location();
79  		location.setId("1");
80  		when(service.getLocationById(any(String.class))).thenReturn(null).thenReturn(location);
81  		Object viewObject = getCxfService().get("0");
82  		assertTrue("returned class does not match", viewObject.getClass().equals(new ResponseEntity<String>(HttpStatus.NOT_FOUND).getClass()));
83  		viewObject = getCxfService().get("1");
84  		assertTrue("returned object does not match test object", viewObject.equals(location.toJson()));
85      }
86      
87      @Test
88      public void testGetFoursuareData() {
89      	
90      }
91      
92      @Test
93      public void testGetFoursquareDataId() {
94      	
95      }
96      
97      @Test
98  	public void testNothing(){
99  		assertTrue("Nothing is true.", true);
100 		assertFalse("Nothing is false.", false);
101 	}
102 
103 	public MapsService getService() {
104 		return service;
105 	}
106 
107 	public void setService(MapsService service) {
108 		this.service = service;
109 	}
110 
111 	public CXFMapsService getCxfService() {
112 		return cxfService;
113 	}
114 
115 	public void setCxfService(CXFMapsService cxfService) {
116 		this.cxfService = cxfService;
117 	}
118 
119 	public ConfigParamService getConfigParamService() {
120 		return configParamService;
121 	}
122 
123 	public void setConfigParamService(ConfigParamService configParamService) {
124 		this.configParamService = configParamService;
125 	}
126 }