Search in sources :

Example 21 with ReportPortalException

use of com.epam.ta.reportportal.exception.ReportPortalException in project commons-dao by reportportal.

the class TestItemRepositoryTest method findByPath.

@Test
void findByPath() {
    TestItem testItem = testItemRepository.findById(1L).orElseThrow(() -> new ReportPortalException(ErrorType.TEST_ITEM_NOT_FOUND, 1L));
    assertTrue(testItemRepository.findByPath(testItem.getPath()).isPresent());
}
Also used : ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) IndexTestItem(com.epam.ta.reportportal.ws.model.analyzer.IndexTestItem) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 22 with ReportPortalException

use of com.epam.ta.reportportal.exception.ReportPortalException in project commons-dao by reportportal.

the class WidgetSortUtils method transformToField.

private static Field<Object> transformToField(FilterTarget filterTarget, Sort.Order order, String tableName) {
    BusinessRule.expect(filterTarget, Objects::nonNull).verify(ErrorType.UNCLASSIFIED_REPORT_PORTAL_ERROR, "Provided value shouldn't be null");
    String filterCriteria;
    if (order.getProperty().startsWith(STATISTICS_KEY)) {
        filterCriteria = order.getProperty();
    } else {
        filterCriteria = filterTarget.getCriteriaByFilter(order.getProperty()).orElseThrow(() -> new ReportPortalException(ErrorType.INCORRECT_SORTING_PARAMETERS, order.getProperty())).getFilterCriteria();
    }
    return field(name(tableName, filterCriteria));
}
Also used : ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException)

Example 23 with ReportPortalException

use of com.epam.ta.reportportal.exception.ReportPortalException in project commons-dao by reportportal.

the class AttachmentDataStoreServiceTest method saveLoadAndDeleteThumbnailTest.

@Test
void saveLoadAndDeleteThumbnailTest() throws IOException {
    InputStream inputStream = new ClassPathResource("meh.jpg").getInputStream();
    String thumbnailId = attachmentDataStoreService.saveThumbnail(random.nextLong() + "thumbnail.jpg", inputStream);
    Optional<InputStream> loadedData = attachmentDataStoreService.load(thumbnailId);
    assertTrue(loadedData.isPresent());
    assertTrue(Files.exists(Paths.get(storageRootPath, attachmentDataStoreService.dataEncoder.decode(thumbnailId))));
    attachmentDataStoreService.delete(thumbnailId);
    ReportPortalException exception = assertThrows(ReportPortalException.class, () -> attachmentDataStoreService.load(thumbnailId));
    assertEquals("Unable to load binary data by id 'Unable to find file'", exception.getMessage());
    assertFalse(Files.exists(Paths.get(storageRootPath, attachmentDataStoreService.dataEncoder.decode(thumbnailId))));
}
Also used : ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) InputStream(java.io.InputStream) ClassPathResource(org.springframework.core.io.ClassPathResource) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 24 with ReportPortalException

use of com.epam.ta.reportportal.exception.ReportPortalException in project commons-dao by reportportal.

the class UserDataStoreServiceTest method saveLoadAndDeleteTest.

@Test
void saveLoadAndDeleteTest() throws IOException {
    InputStream inputStream = new ClassPathResource("meh.jpg").getInputStream();
    String fileId = userDataStoreService.save(random.nextLong() + "meh.jpg", inputStream);
    Optional<InputStream> loadedData = userDataStoreService.load(fileId);
    assertTrue(loadedData.isPresent());
    assertTrue(Files.exists(Paths.get(storageRootPath, userDataStoreService.dataEncoder.decode(fileId))));
    userDataStoreService.delete(fileId);
    ReportPortalException exception = assertThrows(ReportPortalException.class, () -> userDataStoreService.load(fileId));
    assertEquals("Unable to load binary data by id 'Unable to find file'", exception.getMessage());
    assertFalse(Files.exists(Paths.get(storageRootPath, userDataStoreService.dataEncoder.decode(fileId))));
}
Also used : ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) InputStream(java.io.InputStream) ClassPathResource(org.springframework.core.io.ClassPathResource) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 25 with ReportPortalException

use of com.epam.ta.reportportal.exception.ReportPortalException in project service-authorization by reportportal.

the class AuthConfigRepositoryImpl method updateExisting.

private Update updateExisting(Object object) {
    try {
        Update update = new Update();
        PropertyUtils.describe(object).entrySet().stream().filter(e -> null != e.getValue()).forEach(it -> update.set(it.getKey(), it.getValue()));
        return update;
    } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
        throw new ReportPortalException("Error during auth config update", e);
    }
}
Also used : ActiveDirectoryConfig(com.epam.reportportal.auth.store.entity.ldap.ActiveDirectoryConfig) AuthIntegrationType(com.epam.reportportal.auth.integration.AuthIntegrationType) PropertyUtils(org.apache.commons.beanutils.PropertyUtils) Criteria.where(org.springframework.data.mongodb.core.query.Criteria.where) Optional.ofNullable(java.util.Optional.ofNullable) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Autowired(org.springframework.beans.factory.annotation.Autowired) LdapConfig(com.epam.reportportal.auth.store.entity.ldap.LdapConfig) Query.query(org.springframework.data.mongodb.core.query.Query.query) Criteria(org.springframework.data.mongodb.core.query.Criteria) Query(org.springframework.data.mongodb.core.query.Query) InvocationTargetException(java.lang.reflect.InvocationTargetException) MongoOperations(org.springframework.data.mongodb.core.MongoOperations) Update(org.springframework.data.mongodb.core.query.Update) Optional(java.util.Optional) AuthConfigEntity(com.epam.reportportal.auth.store.entity.AuthConfigEntity) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Update(org.springframework.data.mongodb.core.query.Update) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)33 Test (org.junit.jupiter.api.Test)7 InputStream (java.io.InputStream)6 AuthIntegrationType (com.epam.reportportal.auth.integration.AuthIntegrationType)5 BaseTest (com.epam.ta.reportportal.BaseTest)5 ClassPathResource (org.springframework.core.io.ClassPathResource)5 Integration (com.epam.ta.reportportal.entity.integration.Integration)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 IntegrationType (com.epam.ta.reportportal.entity.integration.IntegrationType)3 ErrorType (com.epam.ta.reportportal.ws.model.ErrorType)3 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)3 Filter (com.epam.ta.reportportal.commons.querygen.Filter)2 QueryBuilder (com.epam.ta.reportportal.commons.querygen.QueryBuilder)2 ID (com.epam.ta.reportportal.dao.constant.WidgetRepositoryConstants.ID)2 JooqFieldNameTransformer.fieldName (com.epam.ta.reportportal.dao.util.JooqFieldNameTransformer.fieldName)2 QueryUtils (com.epam.ta.reportportal.dao.util.QueryUtils)2 ServerSettings (com.epam.ta.reportportal.database.entity.settings.ServerSettings)2 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)2 Log (com.epam.ta.reportportal.entity.log.Log)2 JStatusEnum (com.epam.ta.reportportal.jooq.enums.JStatusEnum)2