From 943a47187dbb1393d720b2fdf0019d48270edb4d Mon Sep 17 00:00:00 2001 From: PawelSzalapski Date: Thu, 21 Jun 2018 12:12:30 +0200 Subject: Remove dead code from VESCollector Many things there are unused or have inproper modifiers, spelling etc. I run static analysis tool (Intellij code inspect) and clear those things up. It will be easier to maintain now. No actual behavior changes were done. Issue-ID: DCAEGEN2-526 Signed-off-by: PawelSzalapski Change-Id: I1a4ad0c896bd32165cba654344ffc5245648c615 --- .../onap/dcae/commonFunction/TestCommonStartup.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'src/test/java/org/onap/dcae/commonFunction/TestCommonStartup.java') diff --git a/src/test/java/org/onap/dcae/commonFunction/TestCommonStartup.java b/src/test/java/org/onap/dcae/commonFunction/TestCommonStartup.java index 18194864..e0fd5a42 100644 --- a/src/test/java/org/onap/dcae/commonFunction/TestCommonStartup.java +++ b/src/test/java/org/onap/dcae/commonFunction/TestCommonStartup.java @@ -19,6 +19,8 @@ */ package org.onap.dcae.commonFunction; +import static java.util.Base64.getDecoder; +import static java.util.Base64.getEncoder; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; @@ -34,7 +36,6 @@ import com.google.gson.JsonElement; import com.google.gson.JsonParser; import java.io.FileReader; import java.io.IOException; -import java.util.Base64; import java.util.Map; import java.util.concurrent.LinkedBlockingQueue; import org.json.JSONArray; @@ -77,7 +78,7 @@ public class TestCommonStartup { @Test public void testParseStreamIdToStreamHashMapping() { // given - CommonStartup.streamid = "fault=sec_fault|syslog=sec_syslog|heartbeat=sec_heartbeat|measurementsForVfScaling=sec_measurement|mobileFlow=sec_mobileflow|other=sec_other|stateChange=sec_statechange|thresholdCrossingAlert=sec_thresholdCrossingAlert|voiceQuality=ves_voicequality|sipSignaling=ves_sipsignaling"; + CommonStartup.streamID = "fault=sec_fault|syslog=sec_syslog|heartbeat=sec_heartbeat|measurementsForVfScaling=sec_measurement|mobileFlow=sec_mobileflow|other=sec_other|stateChange=sec_statechange|thresholdCrossingAlert=sec_thresholdCrossingAlert|voiceQuality=ves_voicequality|sipSignaling=ves_sipsignaling"; EventProcessor eventProcessor = new EventProcessor(); // when @@ -95,7 +96,7 @@ public class TestCommonStartup { String user1 = "secureid"; String password1Hashed = "IWRjYWVSb2FkbTEyMyEt"; - String password1UnHashed = decode("IWRjYWVSb2FkbTEyMyEt"); + String password1UnHashed = new String(getDecoder().decode("IWRjYWVSb2FkbTEyMyEt")); String user2 = "sample1"; String password2Hashed = "c2FtcGxlMQ"; @@ -105,24 +106,17 @@ public class TestCommonStartup { DrumlinRequest drumlinRequestMock = Mockito.mock(DrumlinRequest.class); - String basicHeaderForUser1 = "Basic " + encode(user1, password1UnHashed); + String basicHeaderForUser1 = "Basic " + getEncoder().encodeToString((user1 + ":" + password1UnHashed).getBytes()); when(drumlinRequestMock.getFirstHeader("Authorization")).thenReturn(basicHeaderForUser1); // when - SimpleAuthenticator simpleAuthenticator = (SimpleAuthenticator) rsv.AuthlistHandler(authlist); + SimpleAuthenticator simpleAuthenticator = (SimpleAuthenticator) rsv.createAuthenticator(authlist); NsaSimpleApiKey authentic = simpleAuthenticator.isAuthentic(drumlinRequestMock); // then assertEquals(authentic.getSecret(), password1UnHashed); } - private String decode(String hashedPassword) { - return new String(Base64.getDecoder().decode(hashedPassword.getBytes())); - } - - private String encode(String user1, String password1UnHashed) { - return Base64.getEncoder().encodeToString((user1 + ":" + password1UnHashed).getBytes()); - } } -- cgit 1.2.3-korg