blob: 77b3812b2eb63f0b29fc64225b83ca697bdee32f [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() {
Changhoon Yoonbdeb88a2015-05-12 20:35:31 +090036 Application app = new DefaultApplication(APP_ID, VER, DESC, ORIGIN, ROLE,
Thomas Vachuska761f0042015-11-11 19:10:17 -080037 PERMS, Optional.of(FURL), FEATURES, APPS);
Thomas Vachuska02aeb032015-01-06 22:36:30 -080038 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 Yoonbdeb88a2015-05-12 20:35:31 +090042 assertEquals("incorrect role", ROLE, app.role());
Thomas Vachuska02aeb032015-01-06 22:36:30 -080043 assertEquals("incorrect permissions", PERMS, app.permissions());
44 assertEquals("incorrect features repo", FURL, app.featuresRepo().get());
45 assertEquals("incorrect features", FEATURES, app.features());
Thomas Vachuska761f0042015-11-11 19:10:17 -080046 assertEquals("incorrect apps", APPS, app.requiredApps());
Thomas Vachuska02aeb032015-01-06 22:36:30 -080047 assertTrue("incorrect toString", app.toString().contains(APP_NAME));
48 }
49
50 @Test
51 public void testEquality() {
Changhoon Yoonbdeb88a2015-05-12 20:35:31 +090052 Application a1 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN, ROLE,
Thomas Vachuska761f0042015-11-11 19:10:17 -080053 PERMS, Optional.of(FURL), FEATURES, APPS);
Changhoon Yoonbdeb88a2015-05-12 20:35:31 +090054 Application a2 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN, ROLE,
Thomas Vachuska761f0042015-11-11 19:10:17 -080055 PERMS, Optional.of(FURL), FEATURES, APPS);
Changhoon Yoonbdeb88a2015-05-12 20:35:31 +090056 Application a3 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN, ROLE,
Thomas Vachuska761f0042015-11-11 19:10:17 -080057 PERMS, Optional.empty(), FEATURES, APPS);
Changhoon Yoonbdeb88a2015-05-12 20:35:31 +090058 Application a4 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN + "asd", ROLE,
Thomas Vachuska761f0042015-11-11 19:10:17 -080059 PERMS, Optional.of(FURL), FEATURES, APPS);
Thomas Vachuska02aeb032015-01-06 22:36:30 -080060 new EqualsTester().addEqualityGroup(a1, a2)
61 .addEqualityGroup(a3).addEqualityGroup(a4).testEquals();
62 }
63
64}