X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Faaf%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Fcm%2Ftest%2FJU_PlaceArtifactInFiles.java;h=f8b082fb45e2710a4130b4a8e8cb18fdeef2a791;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=7afb4cf4c0ee54de1474bdc269e5a202f917eac2;hpb=c060284812fbbc18fcf22eb628c47c251505fe50;p=aaf%2Fauthz.git diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactInFiles.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactInFiles.java index 7afb4cf4..f8b082fb 100644 --- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactInFiles.java +++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/cm/test/JU_PlaceArtifactInFiles.java @@ -40,61 +40,61 @@ import certman.v1_0.CertInfo; public class JU_PlaceArtifactInFiles { - @Mock private Trans transMock; - @Mock private CertInfo certInfoMock; - @Mock private Artifact artiMock; - - private static final String dirName = "src/test/resources/artifacts"; - private static final String nsName = "org.onap.test"; - private static final String luggagePassword = "12345"; // That's the stupidest combination I've ever heard in my life - - private List certs; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - - certs = new ArrayList<>(); - certs.add("cert1"); - certs.add("cert2"); - - when(certInfoMock.getChallenge()).thenReturn(luggagePassword); - when(certInfoMock.getCerts()).thenReturn(certs); - - when(artiMock.getDir()).thenReturn(dirName); - when(artiMock.getNs()).thenReturn(nsName); - } - - @AfterClass - public static void tearDownOnce() { - cleanup(); - PlaceArtifactInFiles.clear(); - } - - @Test - public void test() throws CadiException { - PlaceArtifactInFiles placer = new PlaceArtifactInFiles(); - placer.place(transMock, certInfoMock, artiMock, "machine"); - assertThat(placer._place(transMock, certInfoMock, artiMock), is(true)); - assertThat(new File(dirName + '/' + nsName + ".crt").exists(), is(true)); - assertThat(new File(dirName + '/' + nsName + ".key").exists(), is(true)); - - when(certInfoMock.getCerts()).thenReturn(null); - try { - placer._place(transMock, certInfoMock, artiMock); - fail("Should've thrown an exception"); - } catch (Exception e) { - } - } - - private static void cleanup() { - File dir = new File(dirName); - if (dir.exists()) { - for (File f : dir.listFiles()) { - f.delete(); - } - dir.delete(); - } - } + @Mock private Trans transMock; + @Mock private CertInfo certInfoMock; + @Mock private Artifact artiMock; + + private static final String dirName = "src/test/resources/artifacts"; + private static final String nsName = "org.onap.test"; + private static final String luggagePassword = "12345"; // That's the stupidest combination I've ever heard in my life + + private List certs; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + + certs = new ArrayList<>(); + certs.add("cert1"); + certs.add("cert2"); + + when(certInfoMock.getChallenge()).thenReturn(luggagePassword); + when(certInfoMock.getCerts()).thenReturn(certs); + + when(artiMock.getDir()).thenReturn(dirName); + when(artiMock.getNs()).thenReturn(nsName); + } + + @AfterClass + public static void tearDownOnce() { + cleanup(); + PlaceArtifactInFiles.clear(); + } + + @Test + public void test() throws CadiException { + PlaceArtifactInFiles placer = new PlaceArtifactInFiles(); + placer.place(transMock, certInfoMock, artiMock, "machine"); + assertThat(placer._place(transMock, certInfoMock, artiMock), is(true)); + assertThat(new File(dirName + '/' + nsName + ".crt").exists(), is(true)); + assertThat(new File(dirName + '/' + nsName + ".key").exists(), is(true)); + + when(certInfoMock.getCerts()).thenReturn(null); + try { + placer._place(transMock, certInfoMock, artiMock); + fail("Should've thrown an exception"); + } catch (Exception e) { + } + } + + private static void cleanup() { + File dir = new File(dirName); + if (dir.exists()) { + for (File f : dir.listFiles()) { + f.delete(); + } + dir.delete(); + } + } }