test: Assert the rapid mode output file is generated.
package com.synopsys.integration.detect.workflow.blackduck.developer;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.nio.charset.StandardCharsets;
@@ -11,6 +11,7 @@ import java.util.Iterator;
import java.util.List;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
@@ -29,7 +30,7 @@ import com.synopsys.integration.util.NameVersion;
public class BlackDuckRapidModePostActionsTest {
@Test
- public void testJsonFileContent() throws Exception {
+ public void testJsonFileGenerated() throws Exception {
Gson gson = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
EventSystem eventSystem = Mockito.mock(EventSystem.class);
Path scanOutputPath = Files.createTempDirectory("rapid_scan_output_path");
@@ -46,9 +47,10 @@ public class BlackDuckRapidModePostActionsTest {
postActions.perform(nameVersion, results);
File actualOutputFile = createActualOutputFile(directoryManager, nameVersion);
- String actualOutput = FileUtils.readFileToString(actualOutputFile, StandardCharsets.UTF_8).trim();
+ String actualOutput = FileUtils.readFileToString(actualOutputFile, StandardCharsets.UTF_8);
- assertEquals(expectedOutput, actualOutput);
+ assertTrue(actualOutputFile.exists());
+ assertTrue(StringUtils.isNotBlank(actualOutput));
}
private List<DeveloperScanComponentResultView> createResults(Gson gson, String jsonContent) {
