summaryrefslogtreecommitdiffstats
path: root/catalog-ui/angular-cli.json
blob: a19145fe12d9b3a3993f0c409453efdbb34d6d3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
  "project": {
    "name": "SDC APP",
    "ejected": true
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets/styles/fonts",
        "assets/styles/images",
        "assets/styles/app.css"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "tsconfig": "tsconfig.json",
      "testTsconfig": "tsconfig.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": [
        "../node_modules/angular/angular.min.js",
        "../node_modules/angular-ui-router/release/angular-ui-router.min.js",
        "../node_modules/restangular/dist/restangular.min.js",
        "../node_modules/angular-filter/dist/angular-filter.min.js",
        "../node_modules/angular-ui-bootstrap/dist/ui-bootstrap.js",
        "../node_modules/angular-bootstrap/ui-bootstrap.min.js",
        "../node_modules/angular-resource/angular-resource.min.js",
        "../node_modules/angular-base64/angular-base64.min.js",
        "../node_modules/angular-uuid4/angular-uuid4.min.js"
      ],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "defaults": {
    "styleExt": "css",
    "class": {
      "spec": false
    },
    "component": {
      "spec": true,
      "inlineStyle": false,
      "inlineTemplate": false
    }
  }
}
bal */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*-
 * ============LICENSE_START=======================================================
 * ONAP
 * ================================================================================
 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.policy.controlloop.actorserviceprovider.pipeline;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.concurrent.Future;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

public class FutureManagerTest {

    private static final String EXPECTED_EXCEPTION = "expected exception";

    @Mock
    private Future<String> future1;

    @Mock
    private Future<String> future2;

    @Mock
    private Future<String> future3;

    private FutureManager mgr;

    /**
     * Initializes fields, including {@link #mgr}.
     */
    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);

        mgr = new FutureManager();
    }

    @Test
    public void testStop() {
        mgr.add(future1);
        mgr.add(future2);
        mgr.add(future3);

        // arrange for one to throw an exception
        when(future2.cancel(anyBoolean())).thenThrow(new IllegalStateException(EXPECTED_EXCEPTION));

        // nothing should have been canceled yet
        verify(future1, never()).cancel(anyBoolean());
        verify(future2, never()).cancel(anyBoolean());
        verify(future3, never()).cancel(anyBoolean());

        assertTrue(mgr.isRunning());

        // stop the controller

        // stop the controller
        mgr.stop();

        // all controllers should now be stopped
        assertFalse(mgr.isRunning());

        // everything should have been invoked
        verify(future1).cancel(anyBoolean());
        verify(future2).cancel(anyBoolean());
        verify(future3).cancel(anyBoolean());

        // re-invoking stop should have no effect on the listeners
        mgr.stop();

        verify(future1).cancel(anyBoolean());
        verify(future2).cancel(anyBoolean());
        verify(future3).cancel(anyBoolean());
    }

    @Test
    public void testAdd() {
        // still running - this should not be invoked
        mgr.add(future1);
        verify(future1, never()).cancel(anyBoolean());

        // re-add should have no impact
        mgr.add(future1);
        verify(future1, never()).cancel(anyBoolean());

        mgr.stop();

        verify(future1).cancel(anyBoolean());

        // new additions should be invoked immediately
        mgr.add(future2);
        verify(future2).cancel(anyBoolean());

        // should work with exceptions, too
        when(future3.cancel(anyBoolean())).thenThrow(new IllegalStateException(EXPECTED_EXCEPTION));
        mgr.add(future3);
    }

    @Test
    public void testRemove() {
        mgr.add(future1);
        mgr.add(future2);

        verify(future1, never()).cancel(anyBoolean());
        verify(future2, never()).cancel(anyBoolean());

        // remove the second
        mgr.remove(future2);

        // should be able to remove it again
        mgr.remove(future2);

        mgr.stop();

        // first should have run, but not the second
        verify(future1).cancel(anyBoolean());

        verify(future2, never()).cancel(anyBoolean());
    }
}