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() { |
Changhoon Yoon | bdeb88a | 2015-05-12 20:35:31 +0900 | [diff] [blame] | 36 | Application app = new DefaultApplication(APP_ID, VER, DESC, ORIGIN, ROLE, |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame^] | 37 | PERMS, Optional.of(FURL), FEATURES, APPS); |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 38 | assertEquals("incorrect id", APP_ID, app.id()); |
| 39 | assertEquals("incorrect version", VER, app.version()); |
| 40 | assertEquals("incorrect description", DESC, app.description()); |
| 41 | assertEquals("incorrect origin", ORIGIN, app.origin()); |
Changhoon Yoon | bdeb88a | 2015-05-12 20:35:31 +0900 | [diff] [blame] | 42 | assertEquals("incorrect role", ROLE, app.role()); |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 43 | assertEquals("incorrect permissions", PERMS, app.permissions()); |
| 44 | assertEquals("incorrect features repo", FURL, app.featuresRepo().get()); |
| 45 | assertEquals("incorrect features", FEATURES, app.features()); |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame^] | 46 | assertEquals("incorrect apps", APPS, app.requiredApps()); |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 47 | assertTrue("incorrect toString", app.toString().contains(APP_NAME)); |
| 48 | } |
| 49 | |
| 50 | @Test |
| 51 | public void testEquality() { |
Changhoon Yoon | bdeb88a | 2015-05-12 20:35:31 +0900 | [diff] [blame] | 52 | Application a1 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN, ROLE, |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame^] | 53 | PERMS, Optional.of(FURL), FEATURES, APPS); |
Changhoon Yoon | bdeb88a | 2015-05-12 20:35:31 +0900 | [diff] [blame] | 54 | Application a2 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN, ROLE, |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame^] | 55 | PERMS, Optional.of(FURL), FEATURES, APPS); |
Changhoon Yoon | bdeb88a | 2015-05-12 20:35:31 +0900 | [diff] [blame] | 56 | Application a3 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN, ROLE, |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame^] | 57 | PERMS, Optional.empty(), FEATURES, APPS); |
Changhoon Yoon | bdeb88a | 2015-05-12 20:35:31 +0900 | [diff] [blame] | 58 | Application a4 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN + "asd", ROLE, |
Thomas Vachuska | 761f004 | 2015-11-11 19:10:17 -0800 | [diff] [blame^] | 59 | PERMS, Optional.of(FURL), FEATURES, APPS); |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 60 | new EqualsTester().addEqualityGroup(a1, a2) |
| 61 | .addEqualityGroup(a3).addEqualityGroup(a4).testEquals(); |
| 62 | } |
| 63 | |
| 64 | } |