blob: f1796dc98650c02da5618ea4f1ec7f662981e83e [file] [log] [blame]
Ray Milkeyf195b022015-02-03 15:13:11 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Ray Milkeyf195b022015-02-03 15:13:11 -08003 *
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 */
Jian Li8ae91202016-03-24 14:36:16 -070016package org.onosproject.rest.resources;
Ray Milkeyf195b022015-02-03 15:13:11 -080017
Jian Li80cfe452016-01-14 16:04:58 -080018import com.eclipsesource.json.Json;
Thomas Vachuskaebf5e542015-02-03 19:38:13 -080019import com.eclipsesource.json.JsonArray;
20import com.eclipsesource.json.JsonObject;
21import com.google.common.collect.ImmutableList;
22import com.google.common.collect.ImmutableSet;
Ray Milkeyf195b022015-02-03 15:13:11 -080023import org.hamcrest.Description;
24import org.hamcrest.TypeSafeMatcher;
Jian Li847242b2016-05-11 18:58:53 -070025import org.junit.Assert;
Ray Milkeyf195b022015-02-03 15:13:11 -080026import org.junit.Before;
27import org.junit.Test;
28import org.onlab.osgi.ServiceDirectory;
29import org.onlab.osgi.TestServiceDirectory;
30import org.onlab.rest.BaseResource;
31import org.onosproject.app.ApplicationAdminService;
32import org.onosproject.app.ApplicationService;
33import org.onosproject.app.ApplicationState;
34import org.onosproject.codec.CodecService;
35import org.onosproject.codec.impl.ApplicationCodec;
36import org.onosproject.codec.impl.CodecManager;
37import org.onosproject.codec.impl.MockCodecContext;
38import org.onosproject.core.Application;
39import org.onosproject.core.ApplicationId;
Changhoon Yoonbdeb88a2015-05-12 20:35:31 +090040import org.onosproject.core.ApplicationRole;
Jian Lie1c1c8d2016-05-09 16:24:40 -070041import org.onosproject.core.CoreService;
Ray Milkeyf195b022015-02-03 15:13:11 -080042import org.onosproject.core.DefaultApplication;
43import org.onosproject.core.DefaultApplicationId;
44import org.onosproject.core.Version;
45
Jian Li847242b2016-05-11 18:58:53 -070046import javax.ws.rs.NotFoundException;
Jian Li9d616492016-03-09 10:52:49 -080047import javax.ws.rs.client.Entity;
48import javax.ws.rs.client.WebTarget;
49import javax.ws.rs.core.MediaType;
Thomas Vachuskaebf5e542015-02-03 19:38:13 -080050import java.io.InputStream;
51import java.net.URI;
52import java.util.Optional;
Ray Milkeyf195b022015-02-03 15:13:11 -080053
Jian Li9d616492016-03-09 10:52:49 -080054import static org.easymock.EasyMock.createMock;
55import static org.easymock.EasyMock.expect;
56import static org.easymock.EasyMock.expectLastCall;
57import static org.easymock.EasyMock.isA;
58import static org.easymock.EasyMock.replay;
59import static org.easymock.EasyMock.verify;
Ray Milkeyf195b022015-02-03 15:13:11 -080060import static org.hamcrest.MatcherAssert.assertThat;
Yuta HIGUCHI293ede02015-02-05 00:08:41 -080061import static org.hamcrest.Matchers.containsString;
62import static org.hamcrest.Matchers.hasSize;
63import static org.hamcrest.Matchers.is;
64import static org.hamcrest.Matchers.notNullValue;
Ray Milkeyf195b022015-02-03 15:13:11 -080065
66/**
67 * Unit tests for applications REST APIs.
68 */
69
70public class ApplicationsResourceTest extends ResourceTest {
71
Jian Lie1c1c8d2016-05-09 16:24:40 -070072 private static class MockCodecContextWithAppService extends MockCodecContext {
73 private ApplicationAdminService appService;
Ray Milkeyf195b022015-02-03 15:13:11 -080074
Jian Lie1c1c8d2016-05-09 16:24:40 -070075 MockCodecContextWithAppService(ApplicationAdminService appService) {
76 this.appService = appService;
Ray Milkeyf195b022015-02-03 15:13:11 -080077 }
78
79 @Override
80 @SuppressWarnings("unchecked")
Ray Milkey3078fc02015-05-06 16:14:14 -070081 public <T> T getService(Class<T> serviceClass) {
Jian Lie1c1c8d2016-05-09 16:24:40 -070082 return (T) appService;
Ray Milkeyf195b022015-02-03 15:13:11 -080083 }
84 }
85
Jian Lie1c1c8d2016-05-09 16:24:40 -070086 private static class MockCodecContextWithCoreService extends MockCodecContext {
87 private CoreService coreService;
88
89 MockCodecContextWithCoreService(CoreService coreService) {
90 this.coreService = coreService;
91 }
92
93 @Override
94 @SuppressWarnings("unchecked")
95 public <T> T getService(Class<T> serviceClass) {
96 return (T) coreService;
97 }
98 }
99
100 private ApplicationAdminService appService;
101 private CoreService coreService;
Ray Milkeyf195b022015-02-03 15:13:11 -0800102 private ApplicationId id1 = new DefaultApplicationId(1, "app1");
103 private ApplicationId id2 = new DefaultApplicationId(2, "app2");
104 private ApplicationId id3 = new DefaultApplicationId(3, "app3");
105 private ApplicationId id4 = new DefaultApplicationId(4, "app4");
106
107 private static final URI FURL = URI.create("mvn:org.foo-features/1.2a/xml/features");
108 private static final Version VER = Version.version(1, 2, "a", null);
109
110 private Application app1 =
Simon Huntafae2f72016-03-04 21:18:23 -0800111 new DefaultApplication(id1, VER, "title1",
Jian Lie1c1c8d2016-05-09 16:24:40 -0700112 "desc1", "origin1", "category1", "url1",
113 "readme1", new byte[0], ApplicationRole.ADMIN,
114 ImmutableSet.of(), Optional.of(FURL),
115 ImmutableList.of("My Feature"), ImmutableList.of());
Ray Milkeyf195b022015-02-03 15:13:11 -0800116 private Application app2 =
Simon Huntafae2f72016-03-04 21:18:23 -0800117 new DefaultApplication(id2, VER, "title2",
Jian Lie1c1c8d2016-05-09 16:24:40 -0700118 "desc2", "origin2", "category2", "url2",
119 "readme2", new byte[0], ApplicationRole.ADMIN,
120 ImmutableSet.of(), Optional.of(FURL),
121 ImmutableList.of("My Feature"), ImmutableList.of());
Ray Milkeyf195b022015-02-03 15:13:11 -0800122 private Application app3 =
Simon Huntafae2f72016-03-04 21:18:23 -0800123 new DefaultApplication(id3, VER, "title3",
Jian Lie1c1c8d2016-05-09 16:24:40 -0700124 "desc3", "origin3", "category3", "url3",
125 "readme3", new byte[0], ApplicationRole.ADMIN,
126 ImmutableSet.of(), Optional.of(FURL),
127 ImmutableList.of("My Feature"), ImmutableList.of());
Ray Milkeyf195b022015-02-03 15:13:11 -0800128 private Application app4 =
Simon Huntafae2f72016-03-04 21:18:23 -0800129 new DefaultApplication(id4, VER, "title4",
Jian Lie1c1c8d2016-05-09 16:24:40 -0700130 "desc4", "origin4", "category4", "url4",
131 "readme4", new byte[0], ApplicationRole.ADMIN,
132 ImmutableSet.of(), Optional.of(FURL),
133 ImmutableList.of("My Feature"), ImmutableList.of());
Ray Milkeyf195b022015-02-03 15:13:11 -0800134
135 /**
Ray Milkeyed0b1662015-02-05 09:34:29 -0800136 * Hamcrest matcher to check that an application representation in JSON matches
Ray Milkeyf195b022015-02-03 15:13:11 -0800137 * the actual device.
138 */
139 private static class AppJsonMatcher extends TypeSafeMatcher<JsonObject> {
140 private final Application app;
141 private String reason = "";
142
143 public AppJsonMatcher(Application appValue) {
144 app = appValue;
145 }
146
147 @Override
148 public boolean matchesSafely(JsonObject jsonApp) {
149 // check id
150 short jsonId = (short) jsonApp.get("id").asInt();
151 if (jsonId != app.id().id()) {
152 reason = "id " + app.id().id();
153 return false;
154 }
155
156 // check name
157 String jsonName = jsonApp.get("name").asString();
158 if (!jsonName.equals(app.id().name())) {
159 reason = "name " + app.id().name();
160 return false;
161 }
162
163 // check origin
164 String jsonOrigin = jsonApp.get("origin").asString();
165 if (!jsonOrigin.equals(app.origin())) {
166 reason = "manufacturer " + app.origin();
167 return false;
168 }
169
170 return true;
171 }
172
173 @Override
174 public void describeTo(Description description) {
175 description.appendText(reason);
176 }
177 }
178
179 /**
Jian Lie1c1c8d2016-05-09 16:24:40 -0700180 * Hamcrest matcher to check that an application id representation in JSON.
181 */
182 private static final class AppIdJsonMatcher extends TypeSafeMatcher<JsonObject> {
183 private final ApplicationId appId;
184 private String reason = "";
185
186 private AppIdJsonMatcher(ApplicationId appId) {
187 this.appId = appId;
188 }
189
190 @Override
191 protected boolean matchesSafely(JsonObject jsonAppId) {
192 // check id
193 short jsonId = (short) jsonAppId.get("id").asInt();
194 if (jsonId != appId.id()) {
195 reason = "id " + appId.id();
196 return false;
197 }
198
199 // check name
200 String jsonName = jsonAppId.get("name").asString();
201 if (!jsonName.equals(appId.name())) {
202 reason = "name " + appId.name();
203 return false;
204 }
205
206 return true;
207 }
208
209 @Override
210 public void describeTo(Description description) {
211 description.appendText(reason);
212 }
213 }
214
215 /**
Ray Milkeyed0b1662015-02-05 09:34:29 -0800216 * Factory to allocate an application matcher.
Ray Milkeyf195b022015-02-03 15:13:11 -0800217 *
218 * @param app application object we are looking for
219 * @return matcher
220 */
221 private static AppJsonMatcher matchesApp(Application app) {
222 return new AppJsonMatcher(app);
223 }
224
Ray Milkeyed0b1662015-02-05 09:34:29 -0800225 /**
Jian Lie1c1c8d2016-05-09 16:24:40 -0700226 * Factory to allocate an application Id matcher.
227 *
228 * @param appId application Id object we are looking for
229 * @return matcher
230 */
231 private static AppIdJsonMatcher matchesAppId(ApplicationId appId) {
232 return new AppIdJsonMatcher(appId);
233 }
234
235 /**
Ray Milkeyed0b1662015-02-05 09:34:29 -0800236 * Initializes test mocks and environment.
237 */
Ray Milkeyf195b022015-02-03 15:13:11 -0800238 @Before
Ray Milkeyed0b1662015-02-05 09:34:29 -0800239 public void setUpMocks() {
Jian Lie1c1c8d2016-05-09 16:24:40 -0700240 appService = createMock(ApplicationAdminService.class);
241 coreService = createMock(CoreService.class);
Ray Milkeyf195b022015-02-03 15:13:11 -0800242
Jian Lie1c1c8d2016-05-09 16:24:40 -0700243 expect(appService.getId("one"))
Ray Milkeyf195b022015-02-03 15:13:11 -0800244 .andReturn(id1)
245 .anyTimes();
Jian Lie1c1c8d2016-05-09 16:24:40 -0700246 expect(appService.getId("two"))
Ray Milkeyf195b022015-02-03 15:13:11 -0800247 .andReturn(id2)
248 .anyTimes();
Jian Lie1c1c8d2016-05-09 16:24:40 -0700249 expect(appService.getId("three"))
Ray Milkeyf195b022015-02-03 15:13:11 -0800250 .andReturn(id3)
251 .anyTimes();
Jian Lie1c1c8d2016-05-09 16:24:40 -0700252 expect(appService.getId("four"))
Ray Milkeyf195b022015-02-03 15:13:11 -0800253 .andReturn(id4)
254 .anyTimes();
255
Jian Lie1c1c8d2016-05-09 16:24:40 -0700256 expect(appService.getApplication(id3))
Ray Milkeyf195b022015-02-03 15:13:11 -0800257 .andReturn(app3)
258 .anyTimes();
Jian Lie1c1c8d2016-05-09 16:24:40 -0700259 expect(appService.getState(isA(ApplicationId.class)))
Ray Milkeyf195b022015-02-03 15:13:11 -0800260 .andReturn(ApplicationState.ACTIVE)
261 .anyTimes();
262
263 // Register the services needed for the test
264 CodecManager codecService = new CodecManager();
265 codecService.activate();
266 ServiceDirectory testDirectory =
267 new TestServiceDirectory()
Jian Lie1c1c8d2016-05-09 16:24:40 -0700268 .add(ApplicationAdminService.class, appService)
269 .add(ApplicationService.class, appService)
270 .add(CoreService.class, coreService)
Ray Milkeyf195b022015-02-03 15:13:11 -0800271 .add(CodecService.class, codecService);
272
273 BaseResource.setServiceDirectory(testDirectory);
274 }
275
Ray Milkeyed0b1662015-02-05 09:34:29 -0800276 /**
Ray Milkeyf195b022015-02-03 15:13:11 -0800277 * Tests a GET of all applications when no applications are present.
278 */
279 @Test
280 public void getAllApplicationsEmpty() {
Jian Lie1c1c8d2016-05-09 16:24:40 -0700281 expect(appService.getApplications())
Ray Milkeyf195b022015-02-03 15:13:11 -0800282 .andReturn(ImmutableSet.of());
Jian Lie1c1c8d2016-05-09 16:24:40 -0700283 replay(appService);
Ray Milkeyf195b022015-02-03 15:13:11 -0800284
Jian Li9d616492016-03-09 10:52:49 -0800285 WebTarget wt = target();
286 String response = wt.path("applications").request().get(String.class);
Ray Milkeyf195b022015-02-03 15:13:11 -0800287 assertThat(response, is("{\"applications\":[]}"));
Jian Lie1c1c8d2016-05-09 16:24:40 -0700288
289 verify(appService);
Ray Milkeyf195b022015-02-03 15:13:11 -0800290 }
291
292 /**
293 * Tests a GET of all applications with data.
294 */
295 @Test
296 public void getAllApplicationsPopulated() {
Jian Lie1c1c8d2016-05-09 16:24:40 -0700297 expect(appService.getApplications())
Ray Milkeyf195b022015-02-03 15:13:11 -0800298 .andReturn(ImmutableSet.of(app1, app2, app3, app4));
Jian Lie1c1c8d2016-05-09 16:24:40 -0700299 replay(appService);
Ray Milkeyf195b022015-02-03 15:13:11 -0800300
Jian Li9d616492016-03-09 10:52:49 -0800301 WebTarget wt = target();
302 String response = wt.path("applications").request().get(String.class);
Ray Milkeyf195b022015-02-03 15:13:11 -0800303 assertThat(response, containsString("{\"applications\":["));
304
Jian Li80cfe452016-01-14 16:04:58 -0800305 JsonObject result = Json.parse(response).asObject();
Ray Milkeyf195b022015-02-03 15:13:11 -0800306 assertThat(result, notNullValue());
307
308 assertThat(result.names(), hasSize(1));
309 assertThat(result.names().get(0), is("applications"));
310
311 JsonArray jsonApps = result.get("applications").asArray();
312 assertThat(jsonApps, notNullValue());
313 assertThat(jsonApps.size(), is(4));
314
315 assertThat(jsonApps.get(0).asObject(), matchesApp(app1));
316 assertThat(jsonApps.get(1).asObject(), matchesApp(app2));
317 assertThat(jsonApps.get(2).asObject(), matchesApp(app3));
318 assertThat(jsonApps.get(3).asObject(), matchesApp(app4));
Jian Lie1c1c8d2016-05-09 16:24:40 -0700319
320 verify(appService);
Ray Milkeyf195b022015-02-03 15:13:11 -0800321 }
322
323 /**
324 * Tests a GET of a single application.
325 */
326 @Test
327 public void getSingleApplication() {
Jian Lie1c1c8d2016-05-09 16:24:40 -0700328 replay(appService);
Ray Milkeyf195b022015-02-03 15:13:11 -0800329
Jian Li9d616492016-03-09 10:52:49 -0800330 WebTarget wt = target();
331 String response = wt.path("applications/three").request().get(String.class);
Ray Milkeyf195b022015-02-03 15:13:11 -0800332
Jian Li80cfe452016-01-14 16:04:58 -0800333 JsonObject result = Json.parse(response).asObject();
Ray Milkeyf195b022015-02-03 15:13:11 -0800334 assertThat(result, notNullValue());
335
336 assertThat(result, matchesApp(app3));
Jian Lie1c1c8d2016-05-09 16:24:40 -0700337
338 verify(appService);
Ray Milkeyf195b022015-02-03 15:13:11 -0800339 }
340
341 /**
342 * Tests a DELETE of a single application - this should
343 * attempt to uninstall it.
344 */
345 @Test
346 public void deleteApplication() {
Jian Lie1c1c8d2016-05-09 16:24:40 -0700347 appService.uninstall(id3);
Ray Milkeyf195b022015-02-03 15:13:11 -0800348 expectLastCall();
349
Jian Lie1c1c8d2016-05-09 16:24:40 -0700350 replay(appService);
Ray Milkeyf195b022015-02-03 15:13:11 -0800351
Jian Li9d616492016-03-09 10:52:49 -0800352 WebTarget wt = target();
353 wt.path("applications/three").request().delete();
Jian Lie1c1c8d2016-05-09 16:24:40 -0700354
355 verify(appService);
Ray Milkeyf195b022015-02-03 15:13:11 -0800356 }
357
358 /**
359 * Tests a DELETE of a single active application - this should
360 * attempt to uninstall it.
361 */
362 @Test
363 public void deleteActiveApplication() {
Jian Lie1c1c8d2016-05-09 16:24:40 -0700364 appService.deactivate(id3);
Ray Milkeyf195b022015-02-03 15:13:11 -0800365 expectLastCall();
366
Jian Lie1c1c8d2016-05-09 16:24:40 -0700367 replay(appService);
Ray Milkeyf195b022015-02-03 15:13:11 -0800368
Jian Li9d616492016-03-09 10:52:49 -0800369 WebTarget wt = target();
370 wt.path("applications/three/active").request().delete();
Jian Lie1c1c8d2016-05-09 16:24:40 -0700371
372 verify(appService);
Ray Milkeyf195b022015-02-03 15:13:11 -0800373 }
374
375 /**
376 * Tests a POST operation to the "active" URL. This should attempt to
377 * activate the application.
378 */
379 @Test
380 public void postActiveApplication() {
Jian Lie1c1c8d2016-05-09 16:24:40 -0700381 appService.activate(id3);
Ray Milkeyf195b022015-02-03 15:13:11 -0800382 expectLastCall();
383
Jian Lie1c1c8d2016-05-09 16:24:40 -0700384 replay(appService);
Ray Milkeyf195b022015-02-03 15:13:11 -0800385
Jian Li9d616492016-03-09 10:52:49 -0800386 WebTarget wt = target();
387 wt.path("applications/three/active").request().post(null);
Jian Lie1c1c8d2016-05-09 16:24:40 -0700388
389 verify(appService);
Ray Milkeyf195b022015-02-03 15:13:11 -0800390 }
391
392 /**
393 * Tests a POST operation. This should attempt to
394 * install the application.
395 */
396 @Test
397 public void postApplication() {
Jian Lie1c1c8d2016-05-09 16:24:40 -0700398 expect(appService.install(isA(InputStream.class)))
Ray Milkeyf195b022015-02-03 15:13:11 -0800399 .andReturn(app4)
400 .once();
401
Jian Lie1c1c8d2016-05-09 16:24:40 -0700402 replay(appService);
Ray Milkeyf195b022015-02-03 15:13:11 -0800403
404 ApplicationCodec codec = new ApplicationCodec();
405 String app4Json = codec.encode(app4,
Jian Lie1c1c8d2016-05-09 16:24:40 -0700406 new MockCodecContextWithAppService(appService))
Ray Milkeyf195b022015-02-03 15:13:11 -0800407 .asText();
408
Jian Li9d616492016-03-09 10:52:49 -0800409 WebTarget wt = target();
410 String response = wt.path("applications").request().post(
411 Entity.entity(app4Json, MediaType.APPLICATION_OCTET_STREAM), String.class);
Ray Milkeyf195b022015-02-03 15:13:11 -0800412
Jian Li80cfe452016-01-14 16:04:58 -0800413 JsonObject result = Json.parse(response).asObject();
Ray Milkeyf195b022015-02-03 15:13:11 -0800414 assertThat(result, notNullValue());
415
416 assertThat(result, matchesApp(app4));
Jian Lie1c1c8d2016-05-09 16:24:40 -0700417
418 verify(appService);
419 }
420
421 /**
422 * Tests a POST operation. This should attempt to register an on/off platform
423 * application ID.
424 */
425 @Test
426 public void postRegisterAppId() {
427 expect(coreService.registerApplication("app1")).andReturn(id1).anyTimes();
428 replay(coreService);
429
430 WebTarget wt = target();
431 wt.path("applications/app1/register").request().post(null);
432
433 verify(coreService);
434 }
435
436 /**
437 * Tests a GET of all application Ids when no applications are present.
438 */
439 @Test
440 public void getAllApplicationIdsEmpty() {
441 expect(coreService.getAppIds()).andReturn(ImmutableSet.of());
442 replay(coreService);
443
444 WebTarget wt = target();
445 String response = wt.path("applications/ids").request().get(String.class);
446 assertThat(response, is("{\"applicationIds\":[]}"));
447
448 verify(coreService);
449 }
450
451 /**
452 * Tests a GET of all application Ids.
453 */
454 @Test
455 public void getAllApplicationIdsPopulated() {
456 expect(coreService.getAppIds())
457 .andReturn(ImmutableSet.of(id1, id2, id3, id4));
458 replay(coreService);
459
460 WebTarget wt = target();
461 String response = wt.path("applications/ids").request().get(String.class);
462
463 assertThat(response, containsString("{\"applicationIds\":["));
464
465 JsonObject result = Json.parse(response).asObject();
466 assertThat(result, notNullValue());
467
468 assertThat(result.names(), hasSize(1));
469 assertThat(result.names().get(0), is("applicationIds"));
470
471 JsonArray jsonApps = result.get("applicationIds").asArray();
472 assertThat(jsonApps, notNullValue());
473 assertThat(jsonApps.size(), is(4));
474
475 assertThat(jsonApps.get(0).asObject(), matchesAppId(id1));
476 assertThat(jsonApps.get(1).asObject(), matchesAppId(id2));
477 assertThat(jsonApps.get(2).asObject(), matchesAppId(id3));
478 assertThat(jsonApps.get(3).asObject(), matchesAppId(id4));
479
480 verify(coreService);
481 }
482
483 /**
484 * Tests a GET of an applicationId entry with the given numeric id.
485 */
486 @Test
487 public void getAppIdByShortId() {
488 expect(coreService.getAppId((short) 1)).andReturn(id1);
489 replay(coreService);
490
491 WebTarget wt = target();
Jian Li847242b2016-05-11 18:58:53 -0700492 String response = wt.path("applications/ids/entry")
493 .queryParam("id", 1).request().get(String.class);
Jian Lie1c1c8d2016-05-09 16:24:40 -0700494
495 JsonObject result = Json.parse(response).asObject();
496 assertThat(result, notNullValue());
497
498 assertThat(result, matchesAppId(id1));
499
500 verify(coreService);
501 }
502
503 /**
504 * Tests a GET of an applicationId entry with the given application name.
505 */
506 @Test
507 public void getAppIdByName() {
508 expect(coreService.getAppId("app2")).andReturn(id2);
509 replay(coreService);
510
511 WebTarget wt = target();
Jian Li847242b2016-05-11 18:58:53 -0700512 String response = wt.path("applications/ids/entry")
Jian Lie1c1c8d2016-05-09 16:24:40 -0700513 .queryParam("name", "app2").request().get(String.class);
514
515 JsonObject result = Json.parse(response).asObject();
516 assertThat(result, notNullValue());
517
518 assertThat(result, matchesAppId(id2));
519
520 verify(coreService);
Ray Milkeyf195b022015-02-03 15:13:11 -0800521 }
Jian Li847242b2016-05-11 18:58:53 -0700522
523 /**
524 * Tests a GET of an applicationId without specifying any parameters.
525 */
526 @Test
527 public void getAppWithNoParam() {
528 WebTarget wt = target();
529
530 try {
531 wt.path("applications/ids/entry").request().get();
532 } catch (NotFoundException ex) {
533 Assert.assertThat(ex.getMessage(),
534 containsString("HTTP 404 Not Found"));
535 }
536 }
Ray Milkeyf195b022015-02-03 15:13:11 -0800537}