Skip to content

Commit

Permalink
fix(uat): update broken UAT test
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeDombo committed Oct 25, 2023
1 parent 55b0f0d commit 2ee0833
Showing 1 changed file with 3 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import org.junit.jupiter.api.io.TempDir;
import org.mockito.junit.jupiter.MockitoExtension;

import java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.function.Consumer;
Expand All @@ -17,19 +16,18 @@ public class LogGeneratorTest {
@TempDir
static Path tempPath;
String logFileName = "localtest";
String logFileExtention = "log";
String logWriteFreqSeconds = "0.1";
String logWriteFreqMs = "100";
String totalLogNumbers = "50";
String fileSizeBytes = "1024";
String fileSizeUnit = "KB";
String componentName = "com.aws.greengrass.artifacts.LogGenerator";
String activeFileName = logFileName + "." + logFileExtention;
String activeFileName = logFileName + ".log";

@Test
void GIVEN_request_THEN_log_file_Created()
throws ClassNotFoundException, IllegalAccessException, InstantiationException {

String[] args = {logFileName, logFileExtention, fileSizeBytes, fileSizeUnit, logWriteFreqSeconds,
String[] args = {logFileName, fileSizeBytes, fileSizeUnit, logWriteFreqMs,
totalLogNumbers, tempPath.toString()};
((Consumer<String[]>) Class.forName(componentName).newInstance()).accept(args);

Expand All @@ -39,25 +37,4 @@ void GIVEN_request_THEN_log_file_Created()
assertTrue(Arrays.asList(pathnames).contains(activeFileName));
assertTrue(tempPath.resolve(activeFileName).toFile().length() > 0);
}

/*
if tempPath is empty string, then the log files would be generated in your local machine. '
This can be used for manually testing if logs are correctly written
*/
@Test
void GIVEN_empty_targetFilePath_in_Paras_THEN_default_path_is_local()
throws ClassNotFoundException, InstantiationException, IllegalAccessException {

String[] args = {logFileName, logFileExtention, fileSizeBytes, fileSizeUnit, logWriteFreqSeconds,
totalLogNumbers, ""};
((Consumer<String[]>) Class.forName(componentName).newInstance()).accept(args);

String localPath = System.getProperty("user.dir");
File directory = new File(localPath);
String[] pathnames = directory.list();
assertTrue(pathnames.length >= 1);
assertTrue(Arrays.asList(pathnames).contains(activeFileName));
assertTrue(new File(localPath + "/" + activeFileName).length() > 0);

}
}

0 comments on commit 2ee0833

Please sign in to comment.