blob: 61538f07ea4881ef08a7163cc1af74208509bedc [file] [log] [blame]
Thomas Vachuska02aeb032015-01-06 22:36:30 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Thomas Vachuska02aeb032015-01-06 22:36:30 -08003 *
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.app;
17
18import org.junit.Test;
19import org.onosproject.core.Application;
20import org.onosproject.core.DefaultApplication;
21import org.onosproject.event.AbstractEventTest;
22
23import java.util.Optional;
24
25import static org.onosproject.app.ApplicationEvent.Type.APP_ACTIVATED;
26import static org.onosproject.app.DefaultApplicationDescriptionTest.*;
27import static org.onosproject.core.DefaultApplicationTest.APP_ID;
28
29/**
30 * Test of the application event.
31 */
32public class ApplicationEventTest extends AbstractEventTest {
33
34 private Application createApp() {
Ray Milkey47c95412017-09-15 10:40:48 -070035 return DefaultApplication.builder()
36 .withAppId(APP_ID)
37 .withVersion(VER)
38 .withTitle(TITLE)
39 .withDescription(DESC)
40 .withOrigin(ORIGIN)
41 .withCategory(CATEGORY)
42 .withUrl(URL)
43 .withReadme(README)
44 .withIcon(ICON)
45 .withRole(ROLE)
46 .withPermissions(PERMS)
47 .withFeaturesRepo(Optional.of(FURL))
48 .withFeatures(FEATURES)
49 .withRequiredApps(APPS)
50 .build();
Thomas Vachuska02aeb032015-01-06 22:36:30 -080051 }
52
53 @Test
54 public void withoutTime() {
55 Application app = createApp();
56 ApplicationEvent event = new ApplicationEvent(APP_ACTIVATED, app, 123L);
57 validateEvent(event, APP_ACTIVATED, app, 123L);
58 }
59
60 @Test
61 public void withTime() {
62 Application app = createApp();
63 long before = System.currentTimeMillis();
64 ApplicationEvent event = new ApplicationEvent(APP_ACTIVATED, app);
65 long after = System.currentTimeMillis();
66 validateEvent(event, APP_ACTIVATED, app, before, after);
67 }
68
Ray Milkey47c95412017-09-15 10:40:48 -070069}