blob: ed0fe6db36792b36415855c4cfef12aab9907ee7 [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() {
36 Application app = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
37 PERMS, Optional.of(FURL), FEATURES);
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());
42 assertEquals("incorrect permissions", PERMS, app.permissions());
43 assertEquals("incorrect features repo", FURL, app.featuresRepo().get());
44 assertEquals("incorrect features", FEATURES, app.features());
45 assertTrue("incorrect toString", app.toString().contains(APP_NAME));
46 }
47
48 @Test
49 public void testEquality() {
50 Application a1 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
51 PERMS, Optional.of(FURL), FEATURES);
52 Application a2 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
53 PERMS, Optional.of(FURL), FEATURES);
54 Application a3 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN,
55 PERMS, Optional.empty(), FEATURES);
56 Application a4 = new DefaultApplication(APP_ID, VER, DESC, ORIGIN + "asd",
57 PERMS, Optional.of(FURL), FEATURES);
58 new EqualsTester().addEqualityGroup(a1, a2)
59 .addEqualityGroup(a3).addEqualityGroup(a4).testEquals();
60 }
61
62}