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

fix entry deletion from database #996

Merged
merged 1 commit into from
Mar 21, 2016
Merged

fix entry deletion from database #996

merged 1 commit into from
Mar 21, 2016

Conversation

chriba
Copy link
Contributor

@chriba chriba commented Mar 18, 2016

Fixes #991, a Bug introduced in b3aee00.

While moving from Map to List as the data structure for the stored BibEntries is has been forgotten to adjust the removeEntry-Method.

  • Change in CHANGELOG.md described?
  • Changes in pull request outlined? (What, why, ...)
  • Tests created for changes?
  • Tests green?

return;
}

entries.remove(oldValue.getId());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, I just fixed that (but worse, just removed the getId()-part). Will removed that commit from my PR.

@koppor
Copy link
Member

koppor commented Mar 18, 2016

Is it really impossible to add a test case?

@koppor koppor added this to the v3.3 milestone Mar 18, 2016
@Test
public void testRemoveEntry() {
BibDatabase db = new BibDatabase();
assertEquals(Collections.emptyList(), db.getEntries());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly, this "assertion" for the subsequent test should be made as separate test. This test is repeated in testInsertEntryKeyCollision. Therefore, I vote for extracting these lines.

@chriba
Copy link
Contributor Author

chriba commented Mar 20, 2016

Enhanced the tests a little bit and added a null-check while inserting an object into the database.

BibDatabase db = new BibDatabase();
assertEquals(Collections.emptyList(), db.getEntries());

db.insertEntry(null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not two different test cases? One for insert null and one for null removal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the Test is very small and tests similar things, I'll extract it.

@koppor
Copy link
Member

koppor commented Mar 21, 2016

LGTM 👍

@koppor koppor added status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers and removed stupro-ready-for-internal-review labels Mar 21, 2016
@@ -158,30 +156,33 @@ public synchronized BibEntry getEntryByKey(String key) {
* use Util.createId(...) to make up a unique ID for an entry.
*/
public synchronized boolean insertEntry(BibEntry entry) throws KeyCollisionException {
if (entry == null){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Objects.requireNonNull is more appropriate here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, didn't knew that trick.

@tobiasdiez
Copy link
Member

Thanks for fixing the bug I had introduced.
The changes look good.

Please try to adhere to the convention for tests outlined in the wiki https://github.com/JabRef/jabref/wiki/Code-Howtos#test-cases, especially the naming of the tests and only one test per test method. Comments test methods shouldn.t be necessary but the test name should contain all the information.

fireDatabaseChanged(new DatabaseChangeEvent(this, DatabaseChangeEvent.ChangeType.ADDED_ENTRY, entry));

return checkForDuplicateKeyAndAdd(null, entry.getCiteKey());
}

/**
* Removes the given entry.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add in the javadoc comment that the entry is removed based on the id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@tobiasdiez
Copy link
Member

After some minor naming improvements, this can be merged in in my opinion. Good job.

tobiasdiez added a commit that referenced this pull request Mar 21, 2016
@tobiasdiez tobiasdiez merged commit 474fd62 into JabRef:master Mar 21, 2016
@chriba chriba deleted the fixEntryDeletion branch March 21, 2016 21:41
@koppor koppor removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Mar 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants