Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edition should not start capitalize letter #6149

Merged
merged 13 commits into from
Mar 29, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions .idea/runConfigurations/JabRef_Main.xml

This file was deleted.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
### Added

- We added support for searching ShortScience for an entry through the user's browser. [#6018](https://github.com/JabRef/jabref/pull/6018)
- We updated EditionChecker to permit edition to start with a number.
fabgio marked this conversation as resolved.
Show resolved Hide resolved
- We added tooltips for most fields in the entry editor containing a short description. [#5847](https://github.com/JabRef/jabref/issues/5847)

### Changed
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/jabref/logic/integrity/EditionChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public Optional<String> checkValue(String value) {

//BibTeX
if (!bibDatabaseContextEdition.isBiblatexMode()) {
if(!isFirstCharDigit(value))
fabgio marked this conversation as resolved.
Show resolved Hide resolved
if (!allowIntegerEdition) {
if (!FIRST_LETTER_CAPITALIZED.test(value.trim())) {
return Optional.of(Localization.lang("should have the first letter capitalized"));
Expand All @@ -66,4 +67,9 @@ public Optional<String> checkValue(String value) {

return Optional.empty();
}
boolean isFirstCharDigit (String input){
fabgio marked this conversation as resolved.
Show resolved Hide resolved
char[] array = input.toCharArray();
return Character.isDigit(array[0]);
fabgio marked this conversation as resolved.
Show resolved Hide resolved

}
}
23 changes: 23 additions & 0 deletions src/test/java/org/jabref/logic/integrity/EditionCheckerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.jabref.logic.integrity;

import org.jabref.model.database.BibDatabaseContext;
import org.junit.jupiter.api.Test;


fabgio marked this conversation as resolved.
Show resolved Hide resolved

import static org.junit.jupiter.api.Assertions.assertTrue;


public class EditionCheckerTest {
boolean allowIntegerEdition;
fabgio marked this conversation as resolved.
Show resolved Hide resolved

@Test
void isFirstCharacterANumber(){
var bibDatabaseContextEdition=new BibDatabaseContext();
var editionChecker=new EditionChecker(bibDatabaseContextEdition,allowIntegerEdition);
fabgio marked this conversation as resolved.
Show resolved Hide resolved
var stringWithNumber="0HelloWorld";
boolean flag=editionChecker.isFirstCharDigit(stringWithNumber);
fabgio marked this conversation as resolved.
Show resolved Hide resolved
assertTrue(flag,"check for true");

fabgio marked this conversation as resolved.
Show resolved Hide resolved
}
}