2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.cadi.cm.test;
24 import static org.junit.Assert.*;
25 import static org.hamcrest.CoreMatchers.*;
26 import static org.mockito.Mockito.*;
32 import org.onap.aaf.cadi.CadiException;
33 import org.onap.aaf.cadi.configure.PlaceArtifactScripts;
34 import org.onap.aaf.misc.env.Trans;
36 import certman.v1_0.Artifacts.Artifact;
37 import certman.v1_0.CertInfo;
39 public class JU_PlaceArtifactScripts {
41 @Mock private Trans transMock;
42 @Mock private CertInfo certInfoMock;
43 @Mock private Artifact artiMock;
45 private static final String dirName = "src/test/resources/artifacts";
46 private static final String nsName = "org.onap.test";
47 private static final String luggagePassword = "12345"; // That's the stupidest combination I've ever heard in my life
48 private static final String notification = "A notification";
49 private static final String osUser = "user"; // That's the stupidest combination I've ever heard in my life
53 MockitoAnnotations.initMocks(this);
55 when(artiMock.getDir()).thenReturn(dirName);
56 when(artiMock.getNs()).thenReturn(nsName);
57 when(artiMock.getNotification()).thenReturn(notification);
58 when(artiMock.getOsUser()).thenReturn(osUser);
60 when(certInfoMock.getChallenge()).thenReturn(luggagePassword);
64 public static void tearDownOnce() {
66 PlaceArtifactScripts.clear();
70 public void test() throws CadiException {
71 PlaceArtifactScripts placer = new PlaceArtifactScripts();
72 placer.place(transMock, certInfoMock, artiMock, "machine");
74 assertThat(new File(dirName + '/' + nsName + ".crontab.sh").exists(), is(true));
75 assertThat(new File(dirName + '/' + nsName + ".check.sh").exists(), is(true));
78 when(artiMock.getNotification()).thenReturn("mailto: " + notification);
79 placer.place(transMock, certInfoMock, artiMock, "machine");
82 private static void cleanup() {
83 File dir = new File(dirName);
85 for (File f : dir.listFiles()) {