blob: 778c23ffb62532a9cbbb423fb07b9f1d4d1bcb78 [file] [log] [blame]
kmcpeake4fe18c82015-11-17 20:07:39 +00001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
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;
kmcpeake4fe18c82015-11-17 20:07:39 +000023import org.onosproject.codec.CodecService;
24import org.onosproject.codec.impl.CodecManager;
Jian Li8ae91202016-03-24 14:36:16 -070025import org.onosproject.rest.resources.ResourceTest;
kmcpeake4fe18c82015-11-17 20:07:39 +000026
Jian Li9d616492016-03-09 10:52:49 -080027import javax.ws.rs.client.WebTarget;
28
29import static org.hamcrest.MatcherAssert.assertThat;
30import static org.hamcrest.Matchers.containsString;
31import static org.hamcrest.Matchers.not;
32
kmcpeake4fe18c82015-11-17 20:07:39 +000033/**
34 * Test of the Fault Management Web REST API for Alarms.
35 */
36public class AlarmsWebResourceTest extends ResourceTest {
37
Jian Li9d616492016-03-09 10:52:49 -080038
39
kmcpeake4fe18c82015-11-17 20:07:39 +000040 @Before
Jian Li9d616492016-03-09 10:52:49 -080041 public void setUpMock() {
kmcpeake4fe18c82015-11-17 20:07:39 +000042
kmcpeakeb172d5f2015-12-10 11:30:43 +000043 CodecManager codecService = new CodecManager();
kmcpeake4fe18c82015-11-17 20:07:39 +000044 codecService.activate();
45
kmcpeakeb172d5f2015-12-10 11:30:43 +000046 ServiceDirectory testDirectory = new TestServiceDirectory()
kmcpeake4fe18c82015-11-17 20:07:39 +000047 // Currently no alarms-service implemented
48 // .add(AlarmsService.class, alarmsService)
49 .add(CodecService.class, codecService);
Ray Milkey094a1352018-01-22 14:03:54 -080050 setServiceDirectory(testDirectory);
kmcpeake4fe18c82015-11-17 20:07:39 +000051 }
52
53 @Test
54 @Ignore
55 public void getAllAlarms() {
Jian Li9d616492016-03-09 10:52:49 -080056 WebTarget wt = target();
57 String response = wt.path("/alarms").request().get(String.class);
kmcpeake4fe18c82015-11-17 20:07:39 +000058 // 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 Li9d616492016-03-09 10:52:49 -080066 WebTarget wt = target();
67 String response = wt.path("/alarms/1").request().get(String.class);
kmcpeake4fe18c82015-11-17 20:07:39 +000068 // Ensure hard-coded alarms returned okay
69 assertThat(response, containsString("\"NE is not reachable\","));
70 assertThat(response, not(containsString("\"Equipment Missing\",")));
71 }
72
73}