diff options
author | PawelSzalapski <pawel.szalapski@nokia.com> | 2018-06-21 12:12:30 +0200 |
---|---|---|
committer | PawelSzalapski <pawel.szalapski@nokia.com> | 2018-06-24 14:18:02 +0200 |
commit | 943a47187dbb1393d720b2fdf0019d48270edb4d (patch) | |
tree | fef76ed7b3034597853ab9735f5052cab2f0d6d5 /src/test/java/org/onap/dcae/commonFunction/TestCommonStartup.java | |
parent | b4d5236a7164b166d49cf8c0a5c15bb848e04cd6 (diff) |
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 <pawel.szalapski@nokia.com>
Change-Id: I1a4ad0c896bd32165cba654344ffc5245648c615
Diffstat (limited to 'src/test/java/org/onap/dcae/commonFunction/TestCommonStartup.java')
-rw-r--r-- | src/test/java/org/onap/dcae/commonFunction/TestCommonStartup.java | 18 |
1 files changed, 6 insertions, 12 deletions
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()); - } } |