Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Thomas Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 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.app; |
| 17 | |
| 18 | import org.junit.Test; |
| 19 | import org.onosproject.core.Application; |
| 20 | import org.onosproject.core.DefaultApplication; |
| 21 | import org.onosproject.event.AbstractEventTest; |
| 22 | |
| 23 | import java.util.Optional; |
| 24 | |
| 25 | import static org.onosproject.app.ApplicationEvent.Type.APP_ACTIVATED; |
| 26 | import static org.onosproject.app.DefaultApplicationDescriptionTest.*; |
| 27 | import static org.onosproject.core.DefaultApplicationTest.APP_ID; |
| 28 | |
| 29 | /** |
| 30 | * Test of the application event. |
| 31 | */ |
| 32 | public class ApplicationEventTest extends AbstractEventTest { |
| 33 | |
| 34 | private Application createApp() { |
Ray Milkey | 47c9541 | 2017-09-15 10:40:48 -0700 | [diff] [blame] | 35 | 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 Vachuska | 02aeb03 | 2015-01-06 22:36:30 -0800 | [diff] [blame] | 51 | } |
| 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 Milkey | 47c9541 | 2017-09-15 10:40:48 -0700 | [diff] [blame] | 69 | } |