kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.faultmanagement.web; |
| 17 | |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 18 | import org.junit.Before; |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 19 | import org.junit.Ignore; |
Jian Li | 9d61649 | 2016-03-09 10:52:49 -0800 | [diff] [blame] | 20 | import org.junit.Test; |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 21 | import org.onlab.osgi.ServiceDirectory; |
| 22 | import org.onlab.osgi.TestServiceDirectory; |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 23 | import org.onosproject.codec.CodecService; |
| 24 | import org.onosproject.codec.impl.CodecManager; |
Jian Li | 8ae9120 | 2016-03-24 14:36:16 -0700 | [diff] [blame] | 25 | import org.onosproject.rest.resources.ResourceTest; |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 26 | |
Jian Li | 9d61649 | 2016-03-09 10:52:49 -0800 | [diff] [blame] | 27 | import javax.ws.rs.client.WebTarget; |
| 28 | |
| 29 | import static org.hamcrest.MatcherAssert.assertThat; |
| 30 | import static org.hamcrest.Matchers.containsString; |
| 31 | import static org.hamcrest.Matchers.not; |
| 32 | |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 33 | /** |
| 34 | * Test of the Fault Management Web REST API for Alarms. |
| 35 | */ |
| 36 | public class AlarmsWebResourceTest extends ResourceTest { |
| 37 | |
Jian Li | 9d61649 | 2016-03-09 10:52:49 -0800 | [diff] [blame] | 38 | |
| 39 | |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 40 | @Before |
Jian Li | 9d61649 | 2016-03-09 10:52:49 -0800 | [diff] [blame] | 41 | public void setUpMock() { |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 42 | |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 43 | CodecManager codecService = new CodecManager(); |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 44 | codecService.activate(); |
| 45 | |
kmcpeake | b172d5f | 2015-12-10 11:30:43 +0000 | [diff] [blame] | 46 | ServiceDirectory testDirectory = new TestServiceDirectory() |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 47 | // Currently no alarms-service implemented |
| 48 | // .add(AlarmsService.class, alarmsService) |
| 49 | .add(CodecService.class, codecService); |
Ray Milkey | 094a135 | 2018-01-22 14:03:54 -0800 | [diff] [blame^] | 50 | setServiceDirectory(testDirectory); |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | @Test |
| 54 | @Ignore |
| 55 | public void getAllAlarms() { |
Jian Li | 9d61649 | 2016-03-09 10:52:49 -0800 | [diff] [blame] | 56 | WebTarget wt = target(); |
| 57 | String response = wt.path("/alarms").request().get(String.class); |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 58 | // Ensure hard-coded alarms returned okay |
| 59 | assertThat(response, containsString("\"NE is not reachable\",")); |
| 60 | assertThat(response, containsString("\"Equipment Missing\",")); |
| 61 | } |
| 62 | |
| 63 | @Test |
| 64 | @Ignore |
| 65 | public void getAlarm() { |
Jian Li | 9d61649 | 2016-03-09 10:52:49 -0800 | [diff] [blame] | 66 | WebTarget wt = target(); |
| 67 | String response = wt.path("/alarms/1").request().get(String.class); |
kmcpeake | 4fe18c8 | 2015-11-17 20:07:39 +0000 | [diff] [blame] | 68 | // Ensure hard-coded alarms returned okay |
| 69 | assertThat(response, containsString("\"NE is not reachable\",")); |
| 70 | assertThat(response, not(containsString("\"Equipment Missing\","))); |
| 71 | } |
| 72 | |
| 73 | } |