Search in sources :

Example 16 with AlertPagedModel

use of com.synopsys.integration.alert.common.rest.model.AlertPagedModel in project hub-alert by blackducksoftware.

the class JobConfigActionsTest method getPageTest.

@Test
public void getPageTest() throws Exception {
    int totalPages = 1;
    int pageNumber = 0;
    int pageSize = 10;
    RegisteredDescriptorModel registeredDescriptorModel = new RegisteredDescriptorModel(1L, "descriptorName", DESCRIPTOR_TYPE.name());
    AlertPagedModel<DistributionJobModel> pageOfJobs = new AlertPagedModel<>(totalPages, pageNumber, pageSize, List.of(distributionJobModel));
    Mockito.when(mockedDescriptorAccessor.getRegisteredDescriptors()).thenReturn(List.of(registeredDescriptorModel));
    Mockito.when(mockedJobAccessor.getPageOfJobs(Mockito.anyInt(), Mockito.anyInt(), Mockito.anyString(), Mockito.anyCollection())).thenReturn(pageOfJobs);
    Mockito.when(mockedConfigurationFieldModelConverter.convertToFieldModel(Mockito.any())).thenReturn(fieldModel);
    ActionResponse<JobPagedModel> jobPagedModelActionResponse = defaultJobConfigActions.getPage(pageNumber, pageSize, "");
    assertTrue(jobPagedModelActionResponse.isSuccessful());
    assertTrue(jobPagedModelActionResponse.hasContent());
    assertEquals(HttpStatus.OK, jobPagedModelActionResponse.getHttpStatus());
}
Also used : JobPagedModel(com.synopsys.integration.alert.common.rest.model.JobPagedModel) RegisteredDescriptorModel(com.synopsys.integration.alert.common.persistence.model.RegisteredDescriptorModel) AlertPagedModel(com.synopsys.integration.alert.common.rest.model.AlertPagedModel) DistributionJobModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel) Test(org.junit.jupiter.api.Test)

Example 17 with AlertPagedModel

use of com.synopsys.integration.alert.common.rest.model.AlertPagedModel in project hub-alert by blackducksoftware.

the class AlertPagedRestModelTest method testRestModel.

@Test
public void testRestModel() {
    final int totalPages = 2;
    final int currentPage = 1;
    final int pageSize = 2;
    List<AuditEntryModel> contentList = new ArrayList<>();
    AuditEntryModel item = new AuditEntryModel();
    contentList.add(item);
    contentList.add(item);
    AlertPagedModel<AuditEntryModel> restModel = new AlertPagedModel<>(totalPages, currentPage, pageSize, contentList);
    assertEquals(totalPages, restModel.getTotalPages());
    assertEquals(currentPage, restModel.getCurrentPage());
    assertEquals(pageSize, restModel.getPageSize());
    assertEquals(contentList, restModel.getModels());
}
Also used : ArrayList(java.util.ArrayList) AlertPagedModel(com.synopsys.integration.alert.common.rest.model.AlertPagedModel) AuditEntryModel(com.synopsys.integration.alert.common.persistence.model.AuditEntryModel) Test(org.junit.jupiter.api.Test)

Aggregations

AlertPagedModel (com.synopsys.integration.alert.common.rest.model.AlertPagedModel)17 PageRequest (org.springframework.data.domain.PageRequest)6 ArrayList (java.util.ArrayList)5 Transactional (org.springframework.transaction.annotation.Transactional)5 ProviderProject (com.synopsys.integration.alert.common.persistence.model.ProviderProject)4 DistributionJobModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel)4 Test (org.junit.jupiter.api.Test)4 ProviderDataAccessor (com.synopsys.integration.alert.common.persistence.accessor.ProviderDataAccessor)3 AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)3 List (java.util.List)3 Optional (java.util.Optional)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 StringUtils (org.apache.commons.lang3.StringUtils)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 ProviderDescriptor (com.synopsys.integration.alert.api.provider.ProviderDescriptor)2 AlertFieldStatus (com.synopsys.integration.alert.common.descriptor.config.field.errors.AlertFieldStatus)2 DistributionWithAuditInfo (com.synopsys.integration.alert.common.rest.model.DistributionWithAuditInfo)2 FieldModel (com.synopsys.integration.alert.common.rest.model.FieldModel)2 DistributionJobEntity (com.synopsys.integration.alert.database.job.DistributionJobEntity)2