Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.core; |
| 17 | |
| 18 | import com.google.common.testing.EqualsTester; |
| 19 | import org.junit.Test; |
| 20 | |
| 21 | import java.util.Optional; |
| 22 | |
| 23 | import static org.junit.Assert.assertEquals; |
| 24 | import static org.junit.Assert.assertTrue; |
| 25 | import static org.onosproject.app.DefaultApplicationDescriptionTest.*; |
| 26 | |
| 27 | /** |
| 28 | * Basic tests of the default app descriptor. |
| 29 | */ |
| 30 | public class DefaultApplicationTest { |
| 31 | |
| 32 | public static final ApplicationId APP_ID = new DefaultApplicationId(2, APP_NAME); |
| 33 | |
| 34 | @Test |
| 35 | public void basics() { |
Jian Li | c35415d | 2016-01-14 17:22:31 -0800 | [diff] [blame] | 36 | Application app = new DefaultApplication(APP_ID, VER, DESC, ORIGIN, |
| 37 | CATEGORY, URL, README, ICON, ROLE, |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame] | 38 | PERMS, Optional.of(FURL), FEATURES, APPS); |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 39 | 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 Li | c35415d | 2016-01-14 17:22:31 -0800 | [diff] [blame] | 43 | 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 Yoon | bdeb88a | 2015-05-12 20:35:31 +0900 | [diff] [blame] | 47 | assertEquals("incorrect role", ROLE, app.role()); |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 48 | assertEquals("incorrect permissions", PERMS, app.permissions()); |
| 49 | assertEquals("incorrect features repo", FURL, app.featuresRepo().get()); |
| 50 | assertEquals("incorrect features", FEATURES, app.features()); |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame] | 51 | assertEquals("incorrect apps", APPS, app.requiredApps()); |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 52 | assertTrue("incorrect toString", app.toString().contains(APP_NAME)); |
| 53 | } |
| 54 | |
| 55 | @Test |
| 56 | public void testEquality() { |
Jian Li | c35415d | 2016-01-14 17:22:31 -0800 | [diff] [blame] | 57 | Application a1 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN, |
| 58 | CATEGORY, URL, README, ICON, ROLE, |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame] | 59 | PERMS, Optional.of(FURL), FEATURES, APPS); |
Jian Li | c35415d | 2016-01-14 17:22:31 -0800 | [diff] [blame] | 60 | Application a2 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN, |
| 61 | CATEGORY, URL, README, ICON, ROLE, |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame] | 62 | PERMS, Optional.of(FURL), FEATURES, APPS); |
Jian Li | c35415d | 2016-01-14 17:22:31 -0800 | [diff] [blame] | 63 | Application a3 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN, |
| 64 | CATEGORY, URL, README, ICON, ROLE, |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame] | 65 | PERMS, Optional.empty(), FEATURES, APPS); |
Jian Li | c35415d | 2016-01-14 17:22:31 -0800 | [diff] [blame] | 66 | Application a4 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN + "asd", |
| 67 | CATEGORY, URL, README, ICON, ROLE, |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame] | 68 | PERMS, Optional.of(FURL), FEATURES, APPS); |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 69 | new EqualsTester().addEqualityGroup(a1, a2) |
| 70 | .addEqualityGroup(a3).addEqualityGroup(a4).testEquals(); |
| 71 | } |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 72 | } |