Skip to content

Commit

Permalink
Fix resolved failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RolfStarre committed Mar 5, 2017
1 parent 9307c76 commit 367085b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ else if (val.matches("edtr\\d+")) {
} else if ("lastpage".equals(val)) {
return lastPage(entry.getField(FieldName.PAGES).orElse(""));
} else if ("title".equals(val)) {
return getTitleWithSignificantWordsCamelized(entry.getField(FieldName.TITLE).orElse(""));
return camelizeSignificantWordsInTitle(entry.getField(FieldName.TITLE).orElse(""));
} else if ("shorttitle".equals(val)) {
return getTitleWords(3, entry.getField(FieldName.TITLE).orElse(""));
} else if ("shorttitleINI".equals(val)) {
Expand Down Expand Up @@ -766,13 +766,6 @@ public static String getCamelizedTitle(String title) {
return keepLettersAndDigitsOnly(camelizeTitle(title));
}

/**
* Capitalises the significant words and concatenates all the words out of the "title" field in the given BibTeX entry
*/
public static String getTitleWithSignificantWordsCamelized(String title) {
return keepLettersAndDigitsOnly(camelizeSignificantWordsInTitle(title));
}

private static String camelizeTitle(String title) {
StringBuilder stringBuilder = new StringBuilder();
String formattedTitle = formatTitle(title);
Expand All @@ -794,7 +787,10 @@ private static String camelizeTitle(String title) {
return stringBuilder.toString();
}

private static String camelizeSignificantWordsInTitle(String title) {
/**
* Capitalises the significant words of the "title" field in the given BibTeX entry
*/
public static String camelizeSignificantWordsInTitle(String title) {
StringBuilder stringBuilder = new StringBuilder();
String formattedTitle = formatTitle(title);
Boolean camelize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,29 +698,30 @@ public void camel() {
*/
@Test
public void title() {
// title capitalises the significant words and concatenates all the words of the title
assertEquals("ApplicationMigrationEffortintheCloudtheCaseofCloudPlatforms",
// title capitalises the significant words of the title
// for the title case the concatenation happens at formatting, which is tested in MakeLabelWithDatabaseTest.java
assertEquals("Application Migration Effort in the Cloud the Case of Cloud Platforms",
BibtexKeyPatternUtil
.getTitleWithSignificantWordsCamelized(TITLE_STRING_ALL_LOWER_FOUR_SMALL_WORDS_ONE_EN_DASH));
assertEquals("BPELConformanceinOpenSourceEnginestheCaseofStaticAnalysis",
BibtexKeyPatternUtil.getTitleWithSignificantWordsCamelized(
.camelizeSignificantWordsInTitle(TITLE_STRING_ALL_LOWER_FOUR_SMALL_WORDS_ONE_EN_DASH));
assertEquals("BPEL Conformance in Open Source Engines: the Case of Static Analysis",
BibtexKeyPatternUtil.camelizeSignificantWordsInTitle(
TITLE_STRING_ALL_LOWER_FIRST_WORD_IN_BRACKETS_TWO_SMALL_WORDS_SMALL_WORD_AFTER_COLON));
assertEquals("ProcessViewingPatterns",
BibtexKeyPatternUtil.getTitleWithSignificantWordsCamelized(TITLE_STRING_CASED));
assertEquals("BPMNConformanceinOpenSourceEngines",
assertEquals("Process Viewing Patterns",
BibtexKeyPatternUtil.camelizeSignificantWordsInTitle(TITLE_STRING_CASED));
assertEquals("BPMN Conformance in Open Source Engines",
BibtexKeyPatternUtil
.getTitleWithSignificantWordsCamelized(TITLE_STRING_CASED_ONE_UPPER_WORD_ONE_SMALL_WORD));
assertEquals("TheDifferencebetweenGraphBasedandBlockStructuredBusinessProcessModellingLanguages",
BibtexKeyPatternUtil.getTitleWithSignificantWordsCamelized(
.camelizeSignificantWordsInTitle(TITLE_STRING_CASED_ONE_UPPER_WORD_ONE_SMALL_WORD));
assertEquals("The Difference between Graph Based and Block Structured Business Process Modelling Languages",
BibtexKeyPatternUtil.camelizeSignificantWordsInTitle(
TITLE_STRING_CASED_TWO_SMALL_WORDS_SMALL_WORD_AT_THE_BEGINNING));
assertEquals("CloudComputingtheNextRevolutioninIT",
BibtexKeyPatternUtil.getTitleWithSignificantWordsCamelized(
assertEquals("Cloud Computing: the Next Revolution in IT",
BibtexKeyPatternUtil.camelizeSignificantWordsInTitle(
TITLE_STRING_CASED_TWO_SMALL_WORDS_SMALL_WORD_AFTER_COLON));
assertEquals("TowardsChoreographyBasedProcessDistributionintheCloud",
assertEquals("Towards Choreography Based Process Distribution in the Cloud",
BibtexKeyPatternUtil
.getTitleWithSignificantWordsCamelized(TITLE_STRING_CASED_TWO_SMALL_WORDS_ONE_CONNECTED_WORD));
assertEquals("OntheMeasurementofDesignTimeAdaptabilityforProcessBasedSystems",
BibtexKeyPatternUtil.getTitleWithSignificantWordsCamelized(
.camelizeSignificantWordsInTitle(TITLE_STRING_CASED_TWO_SMALL_WORDS_ONE_CONNECTED_WORD));
assertEquals("On the Measurement of Design Time Adaptability for Process Based Systems",
BibtexKeyPatternUtil.camelizeSignificantWordsInTitle(
TITLE_STRING_CASED_FOUR_SMALL_WORDS_TWO_CONNECTED_WORDS));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,21 @@ public void generateKeyEmptyFieldColonInDefaultText() {
public void generateKeyTitle() {
bibtexKeyPattern.setDefaultValue("[title]");
BibtexKeyPatternUtil.makeAndSetLabel(bibtexKeyPattern, database, entry, preferences);
assertEquals(Optional.of("AnawesomepaperonJabRef"), entry.getCiteKeyOptional());
assertEquals(Optional.of("AnAwesomePaperonJabRef"), entry.getCiteKeyOptional());
}

@Test
public void generateKeyTitleAbbr() {
bibtexKeyPattern.setDefaultValue("[title:abbr]");
BibtexKeyPatternUtil.makeAndSetLabel(bibtexKeyPattern, database, entry, preferences);
assertEquals(Optional.of("AapoJ"), entry.getCiteKeyOptional());
assertEquals(Optional.of("AAPoJ"), entry.getCiteKeyOptional());
}

@Test
public void generateKeyShorttitle() {
bibtexKeyPattern.setDefaultValue("[shorttitle]");
BibtexKeyPatternUtil.makeAndSetLabel(bibtexKeyPattern, database, entry, preferences);
assertEquals(Optional.of("awesomepaperJabRef"), entry.getCiteKeyOptional());
assertEquals(Optional.of("Anawesomepaper"), entry.getCiteKeyOptional());
}

@Test
Expand All @@ -219,7 +219,7 @@ public void generateKeyVeryshorttitle() {
public void generateKeyShorttitleINI() {
bibtexKeyPattern.setDefaultValue("[shorttitleINI]");
BibtexKeyPatternUtil.makeAndSetLabel(bibtexKeyPattern, database, entry, preferences);
assertEquals(Optional.of("apJ"), entry.getCiteKeyOptional());
assertEquals(Optional.of("Aap"), entry.getCiteKeyOptional());
}

@Test
Expand Down

0 comments on commit 367085b

Please sign in to comment.