Skip to content

Commit

Permalink
:fix: importing org.junit.Assert and explicitly referencing its metho…
Browse files Browse the repository at this point in the history
…ds instead of having test classes extend it

Signed-off-by: dseurotech <davide.salvador@eurotech.com>
  • Loading branch information
dseurotech authored and Coduz committed Oct 28, 2022
1 parent 52b816c commit 9db0917
Show file tree
Hide file tree
Showing 40 changed files with 569 additions and 530 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import java.net.URL;
import java.util.ArrayList;


@Category(JUnitTests.class)
public class AboutEntryTest extends Assert {
public class AboutEntryTest {

private String[] names;
private String[] texts;
Expand All @@ -45,9 +46,9 @@ public void aboutEntryLicenseTest() {
for (String text : texts) {
for (URL url : urls) {
AboutEntry.License license = new AboutEntry.License(name, text, url);
assertEquals("Expected and actual values should be the same.", name, license.getName());
assertEquals("Expected and actual values should be the same.", text, license.getText());
assertEquals("Expected and actual values should be the same.", url, license.getUrl());
Assert.assertEquals("Expected and actual values should be the same.", name, license.getName());
Assert.assertEquals("Expected and actual values should be the same.", text, license.getText());
Assert.assertEquals("Expected and actual values should be the same.", url, license.getUrl());
}
}
}
Expand All @@ -64,10 +65,10 @@ public void licenseGetNameTest() {
}
}
for (int i = 0; i < licenseList.size() / 2; i++) {
assertEquals("Expected and actual values should be the same.", "Name", licenseList.get(i).getName());
Assert.assertEquals("Expected and actual values should be the same.", "Name", licenseList.get(i).getName());
}
for (int i = licenseList.size() / 2; i < licenseList.size(); i++) {
assertNull("Null expected.", licenseList.get(i).getName());
Assert.assertNull("Null expected.", licenseList.get(i).getName());
}
}

Expand All @@ -82,10 +83,10 @@ public void licenseGetTextTest() {
}
}
for (int i = 0; i < licenseList.size() / 2; i++) {
assertEquals("Expected and actual values should be the same.", "Text", licenseList.get(i).getText());
Assert.assertEquals("Expected and actual values should be the same.", "Text", licenseList.get(i).getText());
}
for (int i = licenseList.size() / 2; i < licenseList.size(); i++) {
assertNull("Null expected.", licenseList.get(i).getText());
Assert.assertNull("Null expected.", licenseList.get(i).getText());
}
}

Expand All @@ -100,44 +101,44 @@ public void licenseGetUrlTest() {
}
}
for (int i = 0; i < licenseList.size() / 2; i++) {
assertEquals("Expected and actual values should be the same.", urls[0], licenseList.get(i).getUrl());
Assert.assertEquals("Expected and actual values should be the same.", urls[0], licenseList.get(i).getUrl());
}
for (int i = licenseList.size() / 2; i < licenseList.size(); i++) {
assertNull("Null expected.", licenseList.get(i).getUrl());
Assert.assertNull("Null expected.", licenseList.get(i).getUrl());
}
}

@Test
public void setAndGetIdTest() {
String id = "valid_id";
AboutEntry aboutEntry = new AboutEntry();
assertNull("Null expected.", aboutEntry.getId());
Assert.assertNull("Null expected.", aboutEntry.getId());
aboutEntry.setId(id);
assertEquals("Expected and actual values should be the same.", id, aboutEntry.getId());
Assert.assertEquals("Expected and actual values should be the same.", id, aboutEntry.getId());
aboutEntry.setId(null);
assertNull("Null expected.", aboutEntry.getId());
Assert.assertNull("Null expected.", aboutEntry.getId());
}

@Test
public void setAndGetNameTest() {
String name = "valid_name";
AboutEntry aboutEntry = new AboutEntry();
assertNull("Null expected.", aboutEntry.getName());
Assert.assertNull("Null expected.", aboutEntry.getName());
aboutEntry.setName(name);
assertEquals("Expected and actual values should be the same.", name, aboutEntry.getName());
Assert.assertEquals("Expected and actual values should be the same.", name, aboutEntry.getName());
aboutEntry.setName(null);
assertNull("Null expected.", aboutEntry.getName());
Assert.assertNull("Null expected.", aboutEntry.getName());
}

@Test
public void setAndGetVersionTest() {
String version = "valid_version";
AboutEntry aboutEntry = new AboutEntry();
assertNull("Null expected.", aboutEntry.getVersion());
Assert.assertNull("Null expected.", aboutEntry.getVersion());
aboutEntry.setVersion(version);
assertEquals("Expected and actual values should be the same.", version, aboutEntry.getVersion());
Assert.assertEquals("Expected and actual values should be the same.", version, aboutEntry.getVersion());
aboutEntry.setVersion(null);
assertNull("Null expected.", aboutEntry.getVersion());
Assert.assertNull("Null expected.", aboutEntry.getVersion());
}

@Test
Expand All @@ -152,11 +153,11 @@ public void setAndGetLicenseTest() throws MalformedURLException {
for (String text : texts) {
for (URL url : urls) {
AboutEntry.License license = new AboutEntry.License(name, text, url);
assertEquals("Unknown License expected", "Unknown", aboutEntry.getLicense().getName());
Assert.assertEquals("Unknown License expected", "Unknown", aboutEntry.getLicense().getName());
aboutEntry.setLicense(license);
assertEquals("Expected and actual values should be the same.", license, aboutEntry.getLicense());
Assert.assertEquals("Expected and actual values should be the same.", license, aboutEntry.getLicense());
aboutEntry.setLicense(null);
assertEquals("Unknown License expected", "Unknown", aboutEntry.getLicense().getName());
Assert.assertEquals("Unknown License expected", "Unknown", aboutEntry.getLicense().getName());
}
}
}
Expand All @@ -166,10 +167,10 @@ public void setAndGetLicenseTest() throws MalformedURLException {
public void setAndGetNoticeTest() {
String notice = "valid_notice";
AboutEntry aboutEntry = new AboutEntry();
assertNull("Null expected.", aboutEntry.getNotice());
Assert.assertNull("Null expected.", aboutEntry.getNotice());
aboutEntry.setNotice(notice);
assertEquals("Expected and actual values should be the same.", notice, aboutEntry.getNotice());
Assert.assertEquals("Expected and actual values should be the same.", notice, aboutEntry.getNotice());
aboutEntry.setNotice(null);
assertNull("Null expected.", aboutEntry.getNotice());
Assert.assertNull("Null expected.", aboutEntry.getNotice());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
import java.util.LinkedList;
import java.util.List;


@Category(JUnitTests.class)
public class AboutScannerTest extends Assert {
public class AboutScannerTest {

@Test
public void scanTest() {
final AboutScanner scanner = AboutScanner.scan();
assertNotNull("Null not expected", scanner);
Assert.assertNotNull("Null not expected", scanner);
}

@Test
Expand All @@ -40,19 +41,19 @@ public void getEntriesTest() throws NoSuchFieldException, IllegalAccessException
field.set(aboutScanner, aboutEntry);
final List<AboutEntry> result = aboutScanner.getEntries();

assertEquals("Field wasn't retrieved properly", result, aboutEntry);
Assert.assertEquals("Field wasn't retrieved properly", result, aboutEntry);
}

@Test
public void scanWithParameterTest() {
AboutScanner scanner = AboutScanner.scan(ClasspathHelper.forClassLoader().stream());
assertNotNull("Null not expected", scanner);
Assert.assertNotNull("Null not expected", scanner);

NullPointerException nullPointerException = new NullPointerException();
try {
AboutScanner invalidScanner = AboutScanner.scan(null);
} catch (Exception e) {
assertEquals("NullPointerException expected", nullPointerException.toString(), e.toString());
Assert.assertEquals("NullPointerException expected", nullPointerException.toString(), e.toString());
}
}
}

0 comments on commit 9db0917

Please sign in to comment.