Skip to content

Commit

Permalink
Merge pull request #10678 from bencomp/fix/assert-true-false
Browse files Browse the repository at this point in the history
Assert true or false, not equal to true or false
  • Loading branch information
ofahimIQSS authored Nov 22, 2024
2 parents a159204 + 78f3b46 commit 975907f
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 99 deletions.
10 changes: 5 additions & 5 deletions src/test/java/edu/harvard/iq/dataverse/DatasetFieldTypeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ public void testIsSanitizeHtml() {
//if textbox then sanitize - allow tags
instance.setFieldType(DatasetFieldType.FieldType.TEXTBOX);
result = instance.isSanitizeHtml();
assertEquals(true, result);
assertTrue(result);

//if textbox then don't sanitize - allow tags
instance.setFieldType(DatasetFieldType.FieldType.EMAIL);
result = instance.isSanitizeHtml();
assertEquals(false, result);
assertFalse(result);

//URL, too
instance.setFieldType(DatasetFieldType.FieldType.URL);
result = instance.isSanitizeHtml();
assertEquals(true, result);
assertTrue(result);
}

@Test
Expand Down Expand Up @@ -102,7 +102,7 @@ public void testIsEscapeOutputText(){
//URL, too
instance.setFieldType(DatasetFieldType.FieldType.URL);
result = instance.isEscapeOutputText();
assertEquals(false, result);
assertFalse(result);

}

Expand All @@ -121,7 +121,7 @@ public void testGetSolrField(){
parent.setAllowMultiples(true);
instance.setParentDatasetFieldType(parent);
solrField = instance.getSolrField();
assertEquals(true, solrField.isAllowedToBeMultivalued());
assertTrue(solrField.isAllowedToBeMultivalued());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,63 +52,63 @@ public void testIsValid() {
//Make string too long - should fail.
value.setValue("asdfgX");
result = instance.isValid(value, ctx);
assertEquals(false, result);
assertFalse(result);

//Make string too long - should fail.
value.setValue("asdf");
result = instance.isValid(value, ctx);
assertEquals(false, result);
assertFalse(result);

//Now lets try Dates
dft.setFieldType(DatasetFieldType.FieldType.DATE);
dft.setValidationFormat(null);
value.setValue("1999AD");
result = instance.isValid(value, ctx);
assertEquals(true, result);
assertTrue(result);

value.setValue("44BCE");
result = instance.isValid(value, ctx);
assertEquals(true, result);
assertTrue(result);

value.setValue("2004-10-27");
result = instance.isValid(value, ctx);
assertEquals(true, result);
assertTrue(result);

value.setValue("2002-08");
result = instance.isValid(value, ctx);
assertEquals(true, result);
assertTrue(result);

value.setValue("[1999?]");
result = instance.isValid(value, ctx);
assertEquals(true, result);
assertTrue(result);

value.setValue("Blergh");
result = instance.isValid(value, ctx);
assertEquals(false, result);
assertFalse(result);

//Float
dft.setFieldType(DatasetFieldType.FieldType.FLOAT);
value.setValue("44");
result = instance.isValid(value, ctx);
assertEquals(true, result);
assertTrue(result);

value.setValue("44 1/2");
result = instance.isValid(value, ctx);
assertEquals(false, result);
assertFalse(result);

//Integer
dft.setFieldType(DatasetFieldType.FieldType.INT);
value.setValue("44");
result = instance.isValid(value, ctx);
assertEquals(true, result);
assertTrue(result);

value.setValue("-44");
result = instance.isValid(value, ctx);
assertEquals(true, result);
assertTrue(result);

value.setValue("12.14");
result = instance.isValid(value, ctx);
assertEquals(false, result);
assertFalse(result);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public void testIsInReview() {

DatasetVersion nonDraft = new DatasetVersion();
nonDraft.setVersionState(DatasetVersion.VersionState.RELEASED);
assertEquals(false, nonDraft.isInReview());
assertFalse(nonDraft.isInReview());

ds.addLock(null);
assertFalse(nonDraft.isInReview());
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/edu/harvard/iq/dataverse/api/DatasetsIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -1757,7 +1757,7 @@ public void testPrivateUrl() {

Response privateUrlRoleAssignmentShouldBeGoneAfterDraftDeleted = UtilIT.getRoleAssignmentsOnDataset(datasetId.toString(), null, apiToken);
privateUrlRoleAssignmentShouldBeGoneAfterDraftDeleted.prettyPrint();
assertEquals(false, privateUrlRoleAssignmentShouldBeGoneAfterDraftDeleted.body().asString().contains(privateUrlUser.getIdentifier()));
assertFalse(privateUrlRoleAssignmentShouldBeGoneAfterDraftDeleted.body().asString().contains(privateUrlUser.getIdentifier()));

String newTitleAgain = "I am changing the title again";
Response draftCreatedAgainPostPub = UtilIT.updateDatasetTitleViaSword(dataset1PersistentId, newTitleAgain, apiToken);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/edu/harvard/iq/dataverse/api/SwordIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ public void testDeleteFiles() {
String citation = atomEntryDraftV2.body().xmlPath().getString("entry.bibliographicCitation");
logger.info("citation (should contain 'DRAFT'): " + citation);
boolean draftStringFoundInCitation = citation.matches(".*DRAFT.*");
assertEquals(true, draftStringFoundInCitation);
assertTrue(draftStringFoundInCitation);

List<String> oneFileLeftInV2Draft = statement3.getBody().xmlPath().getList("feed.entry.id");
logger.info("Number of files remaining in this post version 1 draft:" + oneFileLeftInV2Draft.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,20 @@ public void testMutingInJson() {
public void testHasEmailMuted() {
testUser.setMutedEmails(mutedTypes);
System.out.println("hasEmailMuted");
assertEquals(true, testUser.hasEmailMuted(Type.ASSIGNROLE));
assertEquals(true, testUser.hasEmailMuted(Type.REVOKEROLE));
assertEquals(false, testUser.hasEmailMuted(Type.CREATEDV));
assertEquals(false, testUser.hasEmailMuted(null));
assertTrue(testUser.hasEmailMuted(Type.ASSIGNROLE));
assertTrue(testUser.hasEmailMuted(Type.REVOKEROLE));
assertFalse(testUser.hasEmailMuted(Type.CREATEDV));
assertFalse(testUser.hasEmailMuted(null));
}

@Test
public void testHasNotificationsMutedMuted() {
testUser.setMutedNotifications(mutedTypes);
System.out.println("hasNotificationMuted");
assertEquals(true, testUser.hasNotificationMuted(Type.ASSIGNROLE));
assertEquals(true, testUser.hasNotificationMuted(Type.REVOKEROLE));
assertEquals(false, testUser.hasNotificationMuted(Type.CREATEDV));
assertEquals(false, testUser.hasNotificationMuted(null));
assertTrue(testUser.hasNotificationMuted(Type.ASSIGNROLE));
assertTrue(testUser.hasNotificationMuted(Type.REVOKEROLE));
assertFalse(testUser.hasNotificationMuted(Type.CREATEDV));
assertFalse(testUser.hasNotificationMuted(null));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,20 @@ public void tearDownClass() throws IOException {
*/
@Test
public void testOpen() throws IOException {
assertEquals(false, datasetAccess.canRead());
assertEquals(false, datasetAccess.canWrite());
assertFalse(datasetAccess.canRead());
assertFalse(datasetAccess.canWrite());

datasetAccess.open(DataAccessOption.READ_ACCESS);
assertEquals(true, datasetAccess.canRead());
assertEquals(false, datasetAccess.canWrite());
assertTrue(datasetAccess.canRead());
assertFalse(datasetAccess.canWrite());

datasetAccess.open(DataAccessOption.WRITE_ACCESS);
assertEquals(false, datasetAccess.canRead());
assertEquals(true, datasetAccess.canWrite());
assertFalse(datasetAccess.canRead());
assertTrue(datasetAccess.canWrite());

dataFileAccess.open(DataAccessOption.READ_ACCESS);
assertEquals(true, dataFileAccess.canRead());
assertEquals(false, dataFileAccess.canWrite());
assertTrue(dataFileAccess.canRead());
assertFalse(dataFileAccess.canWrite());
}

/**
Expand Down Expand Up @@ -133,7 +133,7 @@ public void testOpenAuxChannel() throws IOException {
*/
@Test
public void testIsAuxObjectCached() throws IOException {
assertEquals(true, datasetAccess.isAuxObjectCached("Dataset"));
assertTrue(datasetAccess.isAuxObjectCached("Dataset"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,48 +189,48 @@ public void testResponseHeaders() {
@Test
public void testFileLocation() {
assertEquals(true, instance.isLocalFile());
assertTrue(instance.isLocalFile());
instance.setIsLocalFile(false);
assertEquals(false, instance.isLocalFile());
assertFalse(instance.isLocalFile());
assertEquals(false, instance.isRemoteAccess());
assertFalse(instance.isRemoteAccess());
instance.setIsRemoteAccess(true);
assertEquals(true, instance.isRemoteAccess());
assertTrue(instance.isRemoteAccess());
}
@Test
public void testHttpAccess() {
assertEquals(false, instance.isHttpAccess());
assertFalse(instance.isHttpAccess());
instance.setIsHttpAccess(true);
assertEquals(true, instance.isHttpAccess());
assertTrue(instance.isHttpAccess());
}*/

@Test
public void testDownloadSupported() {
assertEquals(true, instance.isDownloadSupported());
assertTrue(instance.isDownloadSupported());
instance.setIsDownloadSupported(false);
assertEquals(false, instance.isDownloadSupported());
assertFalse(instance.isDownloadSupported());
}

@Test
public void testSubsetSupported() {
assertEquals(false, instance.isSubsetSupported());
assertFalse(instance.isSubsetSupported());
instance.setIsSubsetSupported(true);
assertEquals(true, instance.isSubsetSupported());
assertTrue(instance.isSubsetSupported());
}

@Test
public void testZippedStream() {
assertEquals(false, instance.isZippedStream());
assertFalse(instance.isZippedStream());
instance.setIsZippedStream(true);
assertEquals(true, instance.isZippedStream());
assertTrue(instance.isZippedStream());
}

@Test
public void testNoVarHeader() {
assertEquals(false, instance.noVarHeader());
assertFalse(instance.noVarHeader());
instance.setNoVarHeader(true);
assertEquals(true, instance.noVarHeader());
assertTrue(instance.noVarHeader());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public void setUpClass() throws IOException {
*/
@Test
public void testPerms() throws IOException {
assertEquals(false, datasetAccess.canRead());
assertEquals(false, datasetAccess.canWrite());
assertFalse(datasetAccess.canRead());
assertFalse(datasetAccess.canWrite());
}

@Test
public void testIsExpiryExpired() {
long currentTime = 1502221467;
assertEquals(false, swiftAccess.isExpiryExpired(60, 1502281, currentTime));
assertFalse(swiftAccess.isExpiryExpired(60, 1502281, currentTime));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@
import org.apache.http.message.BasicStatusLine;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.Test;

public class DataCaptureModuleUtilTest {

@Test
public void testRsyncSupportEnabled() {
System.out.println("rsyncSupportEnabled");
assertEquals(false, DataCaptureModuleUtil.rsyncSupportEnabled(null));
assertEquals(true, DataCaptureModuleUtil.rsyncSupportEnabled("dcm/rsync+ssh"));
assertFalse(DataCaptureModuleUtil.rsyncSupportEnabled(null));
assertTrue(DataCaptureModuleUtil.rsyncSupportEnabled("dcm/rsync+ssh"));
// Comma sepratated lists of upload methods are supported.
assertEquals(false, DataCaptureModuleUtil.rsyncSupportEnabled("native/http:dcm/rsync+ssh"));
assertEquals(true, DataCaptureModuleUtil.rsyncSupportEnabled("native/http,dcm/rsync+ssh"));
assertEquals(false, DataCaptureModuleUtil.rsyncSupportEnabled("native/http"));
assertEquals(false, DataCaptureModuleUtil.rsyncSupportEnabled("junk"));
assertFalse(DataCaptureModuleUtil.rsyncSupportEnabled("native/http:dcm/rsync+ssh"));
assertTrue(DataCaptureModuleUtil.rsyncSupportEnabled("native/http,dcm/rsync+ssh"));
assertFalse(DataCaptureModuleUtil.rsyncSupportEnabled("native/http"));
assertFalse(DataCaptureModuleUtil.rsyncSupportEnabled("junk"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public void testGetThumbnailRestricted() {
*/
@Test
public void testDeleteDatasetLogo() {
assertEquals(false, DatasetUtil.deleteDatasetLogo(null));
assertEquals(false, DatasetUtil.deleteDatasetLogo(new Dataset()));
assertFalse(DatasetUtil.deleteDatasetLogo(null));
assertFalse(DatasetUtil.deleteDatasetLogo(new Dataset()));
}

/**
Expand Down Expand Up @@ -106,7 +106,7 @@ public void testGetThumbnailAsInputStream() {
@Test
public void testIsDatasetLogoPresent() {
Dataset dataset = MocksFactory.makeDataset();
assertEquals(false, DatasetUtil.isDatasetLogoPresent(dataset, ImageThumbConverter.DEFAULT_CARDIMAGE_SIZE));
assertFalse(DatasetUtil.isDatasetLogoPresent(dataset, ImageThumbConverter.DEFAULT_CARDIMAGE_SIZE));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ void variableTest(Map<Long,VariableMetadata> vmMap) {
assertEquals(vm.getLiteralquestion(), "This is a literal question.");
assertEquals(vm.getNotes(), "These are notes.\nA lot of them.");
assertEquals(vm.getUniverse(),"Our universe");
assertEquals(false, vm.isIsweightvar());
assertEquals(false, vm.isWeighted());
assertFalse(vm.isIsweightvar());
assertFalse(vm.isWeighted());

testCategoriesVar1(vm);


vm = vmMap.get(1169L);
assertNotNull(vm);
assertEquals(false, vm.isIsweightvar());
assertEquals(true, vm.isWeighted());
assertFalse(vm.isIsweightvar());
assertTrue(vm.isWeighted());
assertEquals(vm.getLabel(), "age_rollup" );

assertEquals(vm.getInterviewinstruction(), null);
Expand All @@ -90,8 +90,8 @@ void variableTest(Map<Long,VariableMetadata> vmMap) {

vm = vmMap.get(1168L);
assertNotNull(vm);
assertEquals(true, vm.isIsweightvar());
assertEquals(false, vm.isWeighted());
assertTrue(vm.isIsweightvar());
assertFalse(vm.isWeighted());
assertEquals(vm.getLabel(), "weight" );
assertEquals(vm.getInterviewinstruction(), null);
assertEquals(vm.getLiteralquestion(), "Literal question for weight");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,23 +253,23 @@ public void testGetDisplayName() {
*/
@Test
public void testIsXMLFormat() {
assertEquals(false, schemaDotOrgExporter instanceof XMLExporter);
assertFalse(schemaDotOrgExporter instanceof XMLExporter);
}

/**
* Test of isHarvestable method, of class SchemaDotOrgExporter.
*/
@Test
public void testIsHarvestable() {
assertEquals(false, schemaDotOrgExporter.isHarvestable());
assertFalse(schemaDotOrgExporter.isHarvestable());
}

/**
* Test of isAvailableToUsers method, of class SchemaDotOrgExporter.
*/
@Test
public void testIsAvailableToUsers() {
assertEquals(true, schemaDotOrgExporter.isAvailableToUsers());
assertTrue(schemaDotOrgExporter.isAvailableToUsers());
}

/**
Expand Down
Loading

0 comments on commit 975907f

Please sign in to comment.