-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
35548 Allow index-refresh all records
Updated dina-base to support refresh all.
- Loading branch information
Showing
6 changed files
with
114 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/test/java/ca/gc/aafc/objectstore/api/repository/IndexRefreshRepositoryIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package ca.gc.aafc.objectstore.api.repository; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.hateoas.EntityModel; | ||
|
||
import ca.gc.aafc.dina.jpa.BaseDAO; | ||
import ca.gc.aafc.dina.messaging.message.DocumentOperationNotification; | ||
import ca.gc.aafc.dina.messaging.producer.DocumentOperationNotificationMessageProducer; | ||
import ca.gc.aafc.dina.security.auth.DinaAdminCUDAuthorizationService; | ||
import ca.gc.aafc.objectstore.api.BaseIntegrationTest; | ||
import ca.gc.aafc.objectstore.api.dto.IndexRefreshDto; | ||
import ca.gc.aafc.objectstore.api.dto.ObjectStoreMetadataDto; | ||
import ca.gc.aafc.objectstore.api.entities.ObjectStoreMetadata; | ||
import ca.gc.aafc.objectstore.api.entities.ObjectUpload; | ||
import ca.gc.aafc.objectstore.api.service.IndexRefreshService; | ||
import ca.gc.aafc.objectstore.api.testsupport.factories.ObjectStoreMetadataFactory; | ||
import ca.gc.aafc.objectstore.api.testsupport.factories.ObjectUploadFactory; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import javax.inject.Inject; | ||
|
||
public class IndexRefreshRepositoryIT extends BaseIntegrationTest { | ||
|
||
@Inject | ||
private BaseDAO baseDAO; | ||
|
||
@Inject | ||
private DinaAdminCUDAuthorizationService dinaAdminCUDAuthorizationService; | ||
|
||
@Test | ||
public void indexRefreshRepository_onRefreshAll_messageSent() { | ||
// we are not using beans to avoid the RabbitMQ part | ||
List<DocumentOperationNotification> messages = new ArrayList<>(); | ||
DocumentOperationNotificationMessageProducer messageProducer = messages::add; | ||
IndexRefreshService service = new IndexRefreshService(messageProducer, baseDAO); | ||
IndexRefreshRepository repo = new IndexRefreshRepository(dinaAdminCUDAuthorizationService, service); | ||
|
||
ObjectUpload newObjectUpload = objectUploadService.create(ObjectUploadFactory.buildTestObjectUpload()); | ||
ObjectStoreMetadata objectStoreMetadata = ObjectStoreMetadataFactory | ||
.newObjectStoreMetadata() | ||
.fileExtension(null) | ||
.acHashValue(null) | ||
.fileIdentifier(newObjectUpload.getFileIdentifier()) | ||
.build(); | ||
|
||
objectStoreMetaDataService.create(objectStoreMetadata); | ||
|
||
IndexRefreshDto dto = new IndexRefreshDto(); | ||
dto.setDocType(ObjectStoreMetadataDto.TYPENAME); | ||
repo.handlePost(EntityModel.of(dto)); | ||
|
||
// we may get more than 1 message if the database includes records from other tests | ||
assertFalse(messages.isEmpty()); | ||
} | ||
|
||
|
||
} |