blob: 6cb0d0c520c5d4e2372f5acce9a6496efb3a767e [file] [log] [blame]
Thomas Vachuska02aeb032015-01-06 22:36:30 -08001/*
2 * Copyright 2015 Open Networking Laboratory
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 */
16package org.onosproject.core;
17
18import com.google.common.testing.EqualsTester;
19import org.junit.Test;
20
21import java.util.Optional;
22
23import static org.junit.Assert.assertEquals;
24import static org.junit.Assert.assertTrue;
25import static org.onosproject.app.DefaultApplicationDescriptionTest.*;
26
27/**
28 * Basic tests of the default app descriptor.
29 */
30public class DefaultApplicationTest {
31
32 public static final ApplicationId APP_ID = new DefaultApplicationId(2, APP_NAME);
33
34 @Test
35 public void basics() {
Jian Lic35415d2016-01-14 17:22:31 -080036 Application app = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
37 CATEGORY, URL, README, ICON, ROLE,
Thomas Vachuska761f0042015-11-11 19:10:17 -080038 PERMS, Optional.of(FURL), FEATURES, APPS);
Thomas Vachuska02aeb032015-01-06 22:36:30 -080039 assertEquals("incorrect id", APP_ID, app.id());
40 assertEquals("incorrect version", VER, app.version());
41 assertEquals("incorrect description", DESC, app.description());
42 assertEquals("incorrect origin", ORIGIN, app.origin());
Jian Lic35415d2016-01-14 17:22:31 -080043 assertEquals("incorrect category", CATEGORY, app.category());
44 assertEquals("incorrect URL", URL, app.url());
45 assertEquals("incorrect readme", README, app.readme());
46 assertEquals("incorrect icon", ICON, app.icon());
Changhoon Yoonbdeb88a2015-05-12 20:35:31 +090047 assertEquals("incorrect role", ROLE, app.role());
Thomas Vachuska02aeb032015-01-06 22:36:30 -080048 assertEquals("incorrect permissions", PERMS, app.permissions());
49 assertEquals("incorrect features repo", FURL, app.featuresRepo().get());
50 assertEquals("incorrect features", FEATURES, app.features());
Thomas Vachuska761f0042015-11-11 19:10:17 -080051 assertEquals("incorrect apps", APPS, app.requiredApps());
Thomas Vachuska02aeb032015-01-06 22:36:30 -080052 assertTrue("incorrect toString", app.toString().contains(APP_NAME));
53 }
54
55 @Test
56 public void testEquality() {
Jian Lic35415d2016-01-14 17:22:31 -080057 Application a1 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
58 CATEGORY, URL, README, ICON, ROLE,
Thomas Vachuska761f0042015-11-11 19:10:17 -080059 PERMS, Optional.of(FURL), FEATURES, APPS);
Jian Lic35415d2016-01-14 17:22:31 -080060 Application a2 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
61 CATEGORY, URL, README, ICON, ROLE,
Thomas Vachuska761f0042015-11-11 19:10:17 -080062 PERMS, Optional.of(FURL), FEATURES, APPS);
Jian Lic35415d2016-01-14 17:22:31 -080063 Application a3 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
64 CATEGORY, URL, README, ICON, ROLE,
Thomas Vachuska761f0042015-11-11 19:10:17 -080065 PERMS, Optional.empty(), FEATURES, APPS);
Jian Lic35415d2016-01-14 17:22:31 -080066 Application a4 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN + "asd",
67 CATEGORY, URL, README, ICON, ROLE,
Thomas Vachuska761f0042015-11-11 19:10:17 -080068 PERMS, Optional.of(FURL), FEATURES, APPS);
Thomas Vachuska02aeb032015-01-06 22:36:30 -080069 new EqualsTester().addEqualityGroup(a1, a2)
70 .addEqualityGroup(a3).addEqualityGroup(a4).testEquals();
71 }
Thomas Vachuska02aeb032015-01-06 22:36:30 -080072}