Skip to content

Commit

Permalink
Merge pull request #1246 from ORCID/csvUploadedTwice
Browse files Browse the repository at this point in the history
Csv uploaded twice
  • Loading branch information
wjrsimpson authored Aug 15, 2024
2 parents 283db5d + 9de74ed commit b509752
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,10 @@ public List<Assertion> findAssertionsByEmail(String email) {
}

public boolean isDuplicate(Assertion assertion, String salesforceId) {
Assertion normalized = assertionNormalizer.normalize(assertion);
List<Assertion> assertions = assertionRepository.findByEmailAndSalesforceId(assertion.getEmail(), salesforceId);
for (Assertion a : assertions) {
if (duplicates(a, assertion)) {
if (duplicates(a, normalized)) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,7 @@ void testIsDuplicate() {
a.setUrl("something-different");
assertFalse(assertionService.isDuplicate(comparison, DEFAULT_SALESFORCE_ID));


a.setUrl(null);
assertFalse(assertionService.isDuplicate(comparison, DEFAULT_SALESFORCE_ID));

Expand Down Expand Up @@ -1319,6 +1320,7 @@ void testIsDuplicate() {

comparison.setId("not-null"); // id should be ignored
assertTrue(assertionService.isDuplicate(comparison, DEFAULT_SALESFORCE_ID));
verify(assertionNormalizer, Mockito.times(49)).normalize(Mockito.any(Assertion.class)); // check normalization was used
}

@Test
Expand Down Expand Up @@ -1722,10 +1724,10 @@ void testUpdateAssertionsSalesforceId() {
void testUpdateAssertionsSalesforceIdWithFailure() {
List<Assertion> firstPage = getAssertionsForSalesforceId("salesforce-id", 0, AssertionService.REGISTRY_SYNC_BATCH_SIZE);
Mockito.when(assertionRepository.findBySalesforceId(Mockito.eq("salesforce-id"), Mockito.any(Pageable.class))).thenReturn(new PageImpl<Assertion>(firstPage));

// representing updated assertions that need to be rolled back
Mockito.when(assertionRepository.findBySalesforceId(Mockito.eq("new-salesforce-id"), Mockito.any(Pageable.class)))
.thenReturn(new PageImpl<Assertion>(Arrays.asList(new Assertion(), new Assertion(), new Assertion()))).thenReturn(new PageImpl<Assertion>(new ArrayList<>()));
.thenReturn(new PageImpl<Assertion>(Arrays.asList(new Assertion(), new Assertion(), new Assertion()))).thenReturn(new PageImpl<Assertion>(new ArrayList<>()));

// 3 successful updates before error, followed by rollback
Mockito.when(assertionRepository.save(Mockito.any(Assertion.class))).thenReturn(new Assertion()).thenReturn(new Assertion()).thenReturn(new Assertion())
Expand All @@ -1734,8 +1736,8 @@ void testUpdateAssertionsSalesforceIdWithFailure() {
boolean success = assertionService.updateAssertionsSalesforceId("salesforce-id", "new-salesforce-id");
assertThat(success).isFalse();

// 3 updates followed by 1 failure and 3 rollbacks
Mockito.verify(assertionRepository, Mockito.times(7)).save(assertionCaptor.capture());
// 3 updates followed by 1 failure and 3 rollbacks
Mockito.verify(assertionRepository, Mockito.times(7)).save(assertionCaptor.capture());
List<Assertion> saved = assertionCaptor.getAllValues();
assertThat(saved.get(0).getSalesforceId()).isEqualTo("new-salesforce-id");
assertThat(saved.get(1).getSalesforceId()).isEqualTo("new-salesforce-id");
Expand All @@ -1745,7 +1747,7 @@ void testUpdateAssertionsSalesforceIdWithFailure() {
assertThat(saved.get(5).getSalesforceId()).isEqualTo("salesforce-id");
assertThat(saved.get(6).getSalesforceId()).isEqualTo("salesforce-id");
}

private List<MemberAssertionStatusCount> getDummyAssertionStatusCounts() {
List<MemberAssertionStatusCount> counts = new ArrayList<>();
counts.add(new MemberAssertionStatusCount("salesforceId1", "PENDING", 4));
Expand Down
2 changes: 0 additions & 2 deletions ui/src/app/affiliation/affiliation-delete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ export class AffiliationDeletePopupComponent implements OnInit, OnDestroy {

ngOnInit() {
this.activatedRoute.data.subscribe(({ affiliation }) => {
console.log(affiliation)

setTimeout(() => {
this.ngbModalRef = this.modalService.open(AffiliationDeleteDialogComponent as Component, {
size: 'lg',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h4 class="modal-title" i18n="@@gatewayApp.assertionServiceAssertion.import.titl
<button data-cy="confirmCsvUpload" type="submit" class="btn btn-primary" *ngIf="!uploaded">
<fa-icon [icon]="faPlus"></fa-icon>&nbsp;<span i18n="@@entity.action.upload.string">Upload</span>
</button>
<button id="close-dialog" class="btn btn-primary" (click)="close()" *ngIf="uploaded">
<button id="close-dialog" type="button" class="btn btn-primary" (click)="close()" *ngIf="uploaded">
<fa-icon [icon]="faBan"></fa-icon>&nbsp;<span i18n="@@entity.action.close.string">Close</span>
</button>
</div>
Expand Down

0 comments on commit b509752

Please sign in to comment.