Skip to content

Commit

Permalink
- add junit test
Browse files Browse the repository at this point in the history
  • Loading branch information
rathnapandi committed Oct 31, 2024
1 parent 655a135 commit 08833d1
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:
types: [opened, synchronize, reopened]
env:
LOG_LEVEL: debug
LOG_LEVEL: info
jobs:
build:
name: Build and analyze
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.axway.lib;

import com.axway.apim.lib.ExportResult;
import com.axway.apim.lib.error.ErrorCode;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.ArrayList;
import java.util.List;

public class ExportResultTest {

@Test
public void testExportResult() {
ExportResult result = new ExportResult();
result.addExportedFile("api.json");
Assert.assertNotNull(result.getExportedFiles());
Assert.assertEquals(result.getExportedFiles().size(), 1);
}

@Test
public void testErrorCode() {
ExportResult result = new ExportResult();
result.setError(ErrorCode.NO_CHANGE);
Assert.assertTrue(result.hasError());
Assert.assertNotNull(result.getErrorCode());
Assert.assertEquals(result.getErrorCode(), ErrorCode.NO_CHANGE);
}

@Test
public void getRc() {
ExportResult result = new ExportResult();
result.setError(ErrorCode.NO_CHANGE);
Assert.assertNotNull(result.getErrorCode());
Assert.assertEquals(result.getRc(), ErrorCode.NO_CHANGE.getCode());
}

@Test
public void testToString() {
ExportResult result = new ExportResult();
result.setError(ErrorCode.NO_CHANGE);
Assert.assertNotNull(result);
}

@Test
public void restResultDetails() {
List<String> expiredCerts = new ArrayList<>();
expiredCerts.add("dn=axway expired");
ExportResult result = new ExportResult();
result.setResultDetails(expiredCerts);
Assert.assertNotNull(result.getResultDetails());
}
}

0 comments on commit 08833d1

Please sign in to comment.