Skip to content

Commit

Permalink
Make suggested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hasathcharu committed Jun 24, 2024
1 parent 5471902 commit 9aa9c56
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 732 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void execute() {
}
String fileName = argList.get(0);

if (protocol.equals("http")) {
if (protocol.equalsIgnoreCase("http")) {
verifyValidInputsForHttp();
Application codeGenerator = new CodeGenerator();
try {
Expand All @@ -160,7 +160,8 @@ public void execute() {
outStream.println(e.getMessage());
exitError(this.exitWhenFinish);
}
} else if (protocol.equals("ws") || protocol.equals("wss") || protocol.equals("websocket")) {
} else if (protocol.equalsIgnoreCase("ws") || protocol.equalsIgnoreCase("wss") ||
protocol.equalsIgnoreCase("websocket")) {
if (fileName.endsWith(Constants.YAML_EXTENSION) || fileName.endsWith(Constants.JSON_EXTENSION) ||
fileName.endsWith(Constants.YML_EXTENSION)) {
try {
Expand Down Expand Up @@ -331,8 +332,8 @@ public String getName() {
@Override
public void printLongDesc(StringBuilder stringBuilder) {
try (InputStream inputStream = ClassLoader.getSystemResourceAsStream("ballerina-asyncapi.help");
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
BufferedReader br = new BufferedReader(inputStreamReader)) {
InputStreamReader inputStreamReader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);
BufferedReader br = new BufferedReader(inputStreamReader)) {

String content;
while ((content = br.readLine()) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,14 @@ private List<GenSrcFile> generateClientFiles(Path asyncAPI)
String schemaContent = Formatter.format(schemaSyntaxTree).toString();

if (!schemaContent.isBlank()) {
sourceFiles.add(new GenSrcFile(GenSrcFile.GenFileType.MODEL_SRC, TYPE_FILE_NAME,
schemaContent));
sourceFiles.add(new GenSrcFile(GenSrcFile.GenFileType.MODEL_SRC, TYPE_FILE_NAME, schemaContent));
}

// Generate test boilerplate code for test cases
if (this.includeTestFiles) {
TestGenerator testGenerator = new TestGenerator(intermediateClientGenerator);
String testContent = Formatter.format(testGenerator.generateSyntaxTree()).toString();
sourceFiles.add(new GenSrcFile(GenSrcFile.GenFileType.GEN_SRC, TEST_FILE_NAME, testContent));

sourceFiles.add(new GenSrcFile(GenSrcFile.GenFileType.GEN_SRC, TEST_FILE_NAME, testContent));
String configContent = testGenerator.getConfigTomlFile();
if (!configContent.isBlank()) {
sourceFiles.add(new GenSrcFile(GenSrcFile.GenFileType.GEN_SRC, CONFIG_FILE_NAME, configContent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ public class CmdUtils {
/**
* This util method is used to generate {@code Diagnostic} for asyncapi command errors.
*/
public static AsyncAPIDiagnostic constructAsyncAPIDiagnostic
(String code, String message, DiagnosticSeverity severity, Location location, Object... args) {
public static AsyncAPIDiagnostic constructAsyncAPIDiagnostic(String code, String message,
DiagnosticSeverity severity, Location location,
Object... args) {

DiagnosticInfo diagnosticInfo = new DiagnosticInfo(code, message, severity);
if (location == null) {
location = new ConverterCommonUtils.NullLocation();
}
return new AsyncAPIDiagnostic(diagnosticInfo, location,
Collections.emptyList(), args);
return new AsyncAPIDiagnostic(diagnosticInfo, location, Collections.emptyList(), args);
}

/**
Expand Down

This file was deleted.

Loading

0 comments on commit 9aa9c56

Please sign in to comment.