Search in sources :

Example 6 with NotImplementedException

use of alluxio.shaded.client.org.apache.commons.lang3.NotImplementedException in project caravan-rhyme by wcm-io-caravan.

the class RenderResourceStateTest method should_throw_runtime_exception_if_ResourceState_method_throws_exception.

@Test
public void should_throw_runtime_exception_if_ResourceState_method_throws_exception() {
    NotImplementedException cause = new NotImplementedException("not implemented");
    TestResourceWithOptionalState resourceImpl = new TestResourceWithOptionalState() {

        @Override
        public Optional<TestState> getState() {
            throw cause;
        }
    };
    Throwable ex = Assertions.catchThrowable(() -> render(resourceImpl));
    assertThat(ex).isInstanceOf(NotImplementedException.class);
}
Also used : NotImplementedException(org.apache.commons.lang3.NotImplementedException) Assertions.catchThrowable(org.assertj.core.api.Assertions.catchThrowable) TestState(io.wcm.caravan.rhyme.testing.TestState) AsyncHalResourceRendererTestUtil.createTestState(io.wcm.caravan.rhyme.impl.renderer.AsyncHalResourceRendererTestUtil.createTestState) Test(org.junit.jupiter.api.Test)

Example 7 with NotImplementedException

use of alluxio.shaded.client.org.apache.commons.lang3.NotImplementedException in project caravan-rhyme by wcm-io-caravan.

the class JaxRsAsyncHalResponseHandlerImplTest method respondWithError_should_resume_with_fatal_error_thrown_in_handler.

@Test
public void respondWithError_should_resume_with_fatal_error_thrown_in_handler() throws Exception {
    NotImplementedException expectedEx = new NotImplementedException("request URI not availbable");
    Mockito.when(uriInfo.getRequestUri()).thenThrow(expectedEx);
    handler.respondWithError(new RuntimeException("foo"), uriInfo, asyncResponse, metrics);
    Throwable t = verifyResumeHasBeenCalledWithFatalError();
    assertThat(t).isSameAs(expectedEx);
}
Also used : NotImplementedException(org.apache.commons.lang3.NotImplementedException) Test(org.junit.jupiter.api.Test)

Example 8 with NotImplementedException

use of alluxio.shaded.client.org.apache.commons.lang3.NotImplementedException in project caravan-rhyme by wcm-io-caravan.

the class JaxRsAsyncHalResponseHandlerImplTest method respondWith_should_resume_with_fatal_error_thrown_in_handler.

@Test
public void respondWith_should_resume_with_fatal_error_thrown_in_handler() throws Exception {
    NotImplementedException expectedEx = new NotImplementedException("request URI not availbable");
    Mockito.when(uriInfo.getRequestUri()).thenThrow(expectedEx);
    LinkableResource resourceImpl = new LinkableTestResource() {

        @Override
        public Link createLink() {
            return new Link(REQUEST_URL);
        }
    };
    handler.respondWith(resourceImpl, uriInfo, asyncResponse, metrics);
    Throwable t = verifyResumeHasBeenCalledWithFatalError();
    assertThat(t).isSameAs(expectedEx);
}
Also used : NotImplementedException(org.apache.commons.lang3.NotImplementedException) LinkableResource(io.wcm.caravan.rhyme.api.resources.LinkableResource) Link(io.wcm.caravan.hal.resource.Link) Test(org.junit.jupiter.api.Test)

Example 9 with NotImplementedException

use of alluxio.shaded.client.org.apache.commons.lang3.NotImplementedException in project platform by dashjoin.

the class UnionDatabase method getQueryEditor.

/**
 * editor supports noop query and get initial query only
 */
@Override
public QueryEditorInternal getQueryEditor() {
    return new QueryEditorInternal() {

        @Override
        public QueryResponse rename(RenameRequest ac) throws Exception {
            throw new NotImplementedException("not implemented");
        }

        @Override
        public QueryResponse distinct(DistinctRequest ac) throws Exception {
            throw new NotImplementedException("not implemented");
        }

        @Override
        public QueryResponse sort(SortRequest ac) throws Exception {
            throw new NotImplementedException("not implemented");
        }

        @Override
        public QueryResponse addColumn(AddColumnRequest ac) throws Exception {
            throw new NotImplementedException("not implemented");
        }

        @Override
        public QueryResponse removeColumn(RemoveColumnRequest ac) throws Exception {
            throw new NotImplementedException("not implemented");
        }

        @Override
        public QueryResponse setWhere(SetWhereRequest ac) throws Exception {
            throw new NotImplementedException("not implemented");
        }

        @Override
        public QueryResponse setGroupBy(SetWhereRequest ac) throws Exception {
            throw new NotImplementedException("not implemented");
        }

        @Override
        public QueryResponse moveColumn(MoveColumnRequest ac) throws Exception {
            throw new NotImplementedException("not implemented");
        }

        @Override
        public QueryResponse noop(QueryDatabase query) throws Exception {
            AbstractDatabase config = services.getConfig().getDatabase("dj/config");
            QueryResponse res = new QueryResponse();
            res.database = query.database;
            res.query = query.query;
            QueryMeta info = new QueryMeta();
            info.query = query.query;
            res.data = query(info, null);
            Set<String> keys = new HashSet<>();
            for (Map<String, Object> row : res.data) keys.addAll(row.keySet());
            res.joinOptions = Arrays.asList();
            res.fieldNames = new ArrayList<>(keys);
            if (res.fieldNames.remove("ID"))
                res.fieldNames.add(0, "ID");
            res.metadata = new ArrayList<>();
            for (String field : res.fieldNames) {
                QueryColumn qc = new QueryColumn();
                qc.database = UnionDatabase.this.ID;
                qc.col = Col.col(query.query, field);
                Table schema = config.tables.get(query.query);
                if (schema != null) {
                    Property property = schema.properties.get(field);
                    if (property != null) {
                        qc.columnID = property.ID;
                        if (property.pkpos != null)
                            qc.keyTable = query.query;
                        if (property.ref != null)
                            qc.keyTable = property.ref.split("/")[2];
                    }
                }
                res.metadata.add(qc);
            }
            return res;
        }

        @Override
        public QueryResponse getInitialQuery(InitialQueryRequest ac) throws Exception {
            QueryDatabase q = new QueryDatabase();
            Table s = services.getConfig().getSchema(ac.table);
            q.query = s.name;
            q.database = s.parent;
            return noop(q);
        }
    };
}
Also used : Table(org.dashjoin.model.Table) AbstractDatabase(org.dashjoin.model.AbstractDatabase) NotImplementedException(org.apache.commons.lang3.NotImplementedException) MoveColumnRequest(org.dashjoin.service.QueryEditor.MoveColumnRequest) DistinctRequest(org.dashjoin.service.QueryEditor.DistinctRequest) QueryMeta(org.dashjoin.model.QueryMeta) AddColumnRequest(org.dashjoin.service.QueryEditor.AddColumnRequest) QueryDatabase(org.dashjoin.service.QueryEditor.QueryDatabase) RemoveColumnRequest(org.dashjoin.service.QueryEditor.RemoveColumnRequest) SortRequest(org.dashjoin.service.QueryEditor.SortRequest) SetWhereRequest(org.dashjoin.service.QueryEditor.SetWhereRequest) QueryColumn(org.dashjoin.service.QueryEditor.QueryColumn) QueryResponse(org.dashjoin.service.QueryEditor.QueryResponse) InitialQueryRequest(org.dashjoin.service.QueryEditor.InitialQueryRequest) RenameRequest(org.dashjoin.service.QueryEditor.RenameRequest) Property(org.dashjoin.model.Property) HashSet(java.util.HashSet)

Example 10 with NotImplementedException

use of alluxio.shaded.client.org.apache.commons.lang3.NotImplementedException in project backend by CatalogueOfLife.

the class SectorSync method processTree.

private void processTree() {
    final Set<String> blockedIds = decisions.values().stream().filter(ed -> ed.getMode().equals(EditorialDecision.Mode.BLOCK) && ed.getSubject().getId() != null).map(ed -> ed.getSubject().getId()).collect(Collectors.toSet());
    try (SqlSession session = factory.openSession(false);
        TreeCopyHandler treeHandler = new TreeCopyHandler(decisions, factory, nameIndex, user, sector, state)) {
        NameUsageMapper um = session.getMapper(NameUsageMapper.class);
        LOG.info("{} taxon tree {} to {}. Blocking {} nodes", sector.getMode(), sector.getSubject(), sector.getTarget(), blockedIds.size());
        if (sector.getMode() == Sector.Mode.ATTACH) {
            um.processTree(subjectDatasetKey, null, sector.getSubject().getId(), blockedIds, null, true, false).forEach(treeHandler);
        } else if (sector.getMode() == Sector.Mode.UNION) {
            LOG.info("Traverse taxon tree at {}, ignoring immediate children above rank {}. Blocking {} nodes", sector.getSubject().getId(), sector.getPlaceholderRank(), blockedIds.size());
            // see https://github.com/CatalogueOfLife/clearinghouse-ui/issues/518
            for (NameUsageBase child : um.children(DSID.of(subjectDatasetKey, sector.getSubject().getId()), sector.getPlaceholderRank())) {
                if (blockedIds.contains(child.getId())) {
                    LOG.info("Skip blocked child {}", child);
                    continue;
                }
                if (child.isSynonym()) {
                    LOG.info("Add synonym child {}", child);
                    treeHandler.accept(child);
                } else {
                    LOG.info("Traverse child {}", child);
                    um.processTree(subjectDatasetKey, null, child.getId(), blockedIds, null, true, false).forEach(treeHandler);
                }
                treeHandler.reset();
            }
        } else {
            throw new NotImplementedException("Only attach and union sectors are implemented");
        }
        LOG.info("Sync name & taxon relations from sector {}", sectorKey);
        treeHandler.copyRelations();
        // copy handler stats to metrics
        state.setAppliedDecisionCount(treeHandler.decisionCounter);
        state.setIgnoredByReasonCount(Map.copyOf(treeHandler.ignoredCounter));
    }
}
Also used : NotImplementedException(org.apache.commons.lang3.NotImplementedException) LoggerFactory(org.slf4j.LoggerFactory) ImportState(life.catalogue.api.vocab.ImportState) NameIndex(life.catalogue.matching.NameIndex) SectorDao(life.catalogue.dao.SectorDao) EstimateDao(life.catalogue.dao.EstimateDao) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) SqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory) BiConsumer(java.util.function.BiConsumer) EstimateRematcher(life.catalogue.matching.decision.EstimateRematcher) SqlSession(org.apache.ibatis.session.SqlSession) RematchRequest(life.catalogue.matching.decision.RematchRequest) life.catalogue.api.model(life.catalogue.api.model) SectorImportDao(life.catalogue.dao.SectorImportDao) Logger(org.slf4j.Logger) Set(java.util.Set) Collectors(java.util.stream.Collectors) ExecutorType(org.apache.ibatis.session.ExecutorType) Consumer(java.util.function.Consumer) List(java.util.List) SectorProcessable(life.catalogue.db.SectorProcessable) MatchingDao(life.catalogue.matching.decision.MatchingDao) NameUsageIndexService(life.catalogue.es.NameUsageIndexService) life.catalogue.db.mapper(life.catalogue.db.mapper) SqlSession(org.apache.ibatis.session.SqlSession) NotImplementedException(org.apache.commons.lang3.NotImplementedException)

Aggregations

NotImplementedException (org.apache.commons.lang3.NotImplementedException)119 ArrayList (java.util.ArrayList)15 IOException (java.io.IOException)11 Map (java.util.Map)11 Test (org.junit.jupiter.api.Test)10 List (java.util.List)8 HashMap (java.util.HashMap)7 Base64 (org.apache.commons.codec.binary.Base64)5 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)4 Logger (org.slf4j.Logger)4 Description (ca.uhn.fhir.model.api.annotation.Description)3 Operation (ca.uhn.fhir.rest.annotation.Operation)3 ControlFlowNode (fr.inria.controlflow.ControlFlowNode)3 Rhyme (io.wcm.caravan.rhyme.api.Rhyme)3 HalResponse (io.wcm.caravan.rhyme.api.common.HalResponse)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)3 Resource (org.hl7.fhir.r4b.model.Resource)3 Resource (org.hl7.fhir.r5.model.Resource)3 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)3