blob: 8a5cdb22eb13432b30ff6f5164d9f4faf74812b3 [file] [log] [blame]
kmcpeake4fe18c82015-11-17 20:07:39 +00001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
kmcpeake4fe18c82015-11-17 20:07:39 +00003 *
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 */
16package org.onosproject.faultmanagement.web;
17
kmcpeake4fe18c82015-11-17 20:07:39 +000018import org.junit.Before;
kmcpeake4fe18c82015-11-17 20:07:39 +000019import org.junit.Ignore;
Jian Li9d616492016-03-09 10:52:49 -080020import org.junit.Test;
kmcpeake4fe18c82015-11-17 20:07:39 +000021import org.onlab.osgi.ServiceDirectory;
22import org.onlab.osgi.TestServiceDirectory;
23import org.onlab.rest.BaseResource;
24import org.onosproject.codec.CodecService;
25import org.onosproject.codec.impl.CodecManager;
Jian Li8ae91202016-03-24 14:36:16 -070026import org.onosproject.rest.resources.ResourceTest;
kmcpeake4fe18c82015-11-17 20:07:39 +000027
Jian Li9d616492016-03-09 10:52:49 -080028import javax.ws.rs.client.WebTarget;
29
30import static org.hamcrest.MatcherAssert.assertThat;
31import static org.hamcrest.Matchers.containsString;
32import static org.hamcrest.Matchers.not;
33
kmcpeake4fe18c82015-11-17 20:07:39 +000034/**
35 * Test of the Fault Management Web REST API for Alarms.
36 */
37public class AlarmsWebResourceTest extends ResourceTest {
38
Jian Li9d616492016-03-09 10:52:49 -080039
40
kmcpeake4fe18c82015-11-17 20:07:39 +000041 @Before
Jian Li9d616492016-03-09 10:52:49 -080042 public void setUpMock() {
kmcpeake4fe18c82015-11-17 20:07:39 +000043
kmcpeakeb172d5f2015-12-10 11:30:43 +000044 CodecManager codecService = new CodecManager();
kmcpeake4fe18c82015-11-17 20:07:39 +000045 codecService.activate();
46
kmcpeakeb172d5f2015-12-10 11:30:43 +000047 ServiceDirectory testDirectory = new TestServiceDirectory()
kmcpeake4fe18c82015-11-17 20:07:39 +000048 // Currently no alarms-service implemented
49 // .add(AlarmsService.class, alarmsService)
50 .add(CodecService.class, codecService);
51 BaseResource.setServiceDirectory(testDirectory);
52 }
53
54 @Test
55 @Ignore
56 public void getAllAlarms() {
Jian Li9d616492016-03-09 10:52:49 -080057 WebTarget wt = target();
58 String response = wt.path("/alarms").request().get(String.class);
kmcpeake4fe18c82015-11-17 20:07:39 +000059 // Ensure hard-coded alarms returned okay
60 assertThat(response, containsString("\"NE is not reachable\","));
61 assertThat(response, containsString("\"Equipment Missing\","));
62 }
63
64 @Test
65 @Ignore
66 public void getAlarm() {
Jian Li9d616492016-03-09 10:52:49 -080067 WebTarget wt = target();
68 String response = wt.path("/alarms/1").request().get(String.class);
kmcpeake4fe18c82015-11-17 20:07:39 +000069 // Ensure hard-coded alarms returned okay
70 assertThat(response, containsString("\"NE is not reachable\","));
71 assertThat(response, not(containsString("\"Equipment Missing\",")));
72 }
73
74}