Search in sources :

Example 21 with Record

use of org.neo4j.driver.v1.Record in project ORCID-Source by ORCID.

the class ValidateV2_1SamplesTest method testMarshallRecord.

@Test
public void testMarshallRecord() throws JAXBException, SAXException, URISyntaxException {
    Record object = (Record) unmarshallFromPath("/record_2.1/samples/read_samples/record-2.1.xml", Record.class);
    marshall(object, "/record_2.1/record-2.1.xsd");
}
Also used : Record(org.orcid.jaxb.model.record_v2.Record) Test(org.junit.Test)

Example 22 with Record

use of org.neo4j.driver.v1.Record in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method testValidateRecordUsingToken.

@Test
public void testValidateRecordUsingToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewRecord(ORCID);
    assertNotNull(response);
    Record record = (Record) response.getEntity();
    validateRecord(record);
}
Also used : Response(javax.ws.rs.core.Response) Record(org.orcid.jaxb.model.record_v2.Record) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 23 with Record

use of org.neo4j.driver.v1.Record in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method testFindRecord.

@Test
public void testFindRecord() {
    Response response = serviceDelegator.viewRecord(ORCID);
    assertNotNull(response);
    Record record = (Record) response.getEntity();
    validateRecord(record);
}
Also used : Response(javax.ws.rs.core.Response) Record(org.orcid.jaxb.model.record_v2.Record) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 24 with Record

use of org.neo4j.driver.v1.Record in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ReadRecordTest method testViewRecordWrongScope.

@Test
public void testViewRecordWrongScope() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    Response response = serviceDelegator.viewRecord(ORCID);
    // Verify everything inside is public
    Record record = (Record) response.getEntity();
    assertNotNull(record);
    assertEquals("/0000-0000-0000-0003", record.getPath());
    assertEquals("/0000-0000-0000-0003/activities", record.getActivitiesSummary().getPath());
    Utils.assertIsPublicOrSource(record.getActivitiesSummary(), SecurityContextTestUtils.DEFAULT_CLIENT_ID);
    assertEquals("/0000-0000-0000-0003/person", record.getPerson().getPath());
    Utils.assertIsPublicOrSource(record.getPerson(), SecurityContextTestUtils.DEFAULT_CLIENT_ID);
}
Also used : Response(javax.ws.rs.core.Response) GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) Record(org.orcid.jaxb.model.record_v2.Record) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 25 with Record

use of org.neo4j.driver.v1.Record in project open-kilda by telstra.

the class NeoDriver method getPath.

/**
 * {@inheritDoc}
 */
@Override
public ImmutablePair<PathInfoData, PathInfoData> getPath(Flow flow, Strategy strategy) throws UnroutablePathException {
    long latency = 0L;
    List<PathNode> forwardNodes = new LinkedList<>();
    List<PathNode> reverseNodes = new LinkedList<>();
    if (!flow.isOneSwitchFlow()) {
        Statement statement = getPathQuery(flow, strategy);
        logger.debug("QUERY: {}", statement.toString());
        try (Session session = driver.session()) {
            StatementResult result = session.run(statement);
            try {
                Record record = result.next();
                LinkedList<Relationship> isls = new LinkedList<>();
                record.get(0).asPath().relationships().forEach(isls::add);
                int seqId = 0;
                for (Relationship isl : isls) {
                    latency += isl.get("latency").asLong();
                    forwardNodes.add(new PathNode(isl.get("src_switch").asString(), isl.get("src_port").asInt(), seqId, isl.get("latency").asLong()));
                    seqId++;
                    forwardNodes.add(new PathNode(isl.get("dst_switch").asString(), isl.get("dst_port").asInt(), seqId, 0L));
                    seqId++;
                }
                seqId = 0;
                Collections.reverse(isls);
                for (Relationship isl : isls) {
                    reverseNodes.add(new PathNode(isl.get("dst_switch").asString(), isl.get("dst_port").asInt(), seqId, isl.get("latency").asLong()));
                    seqId++;
                    reverseNodes.add(new PathNode(isl.get("src_switch").asString(), isl.get("src_port").asInt(), seqId, 0L));
                    seqId++;
                }
            } catch (NoSuchRecordException e) {
                throw new UnroutablePathException(flow);
            }
        }
    } else {
        logger.info("No path computation for one-switch flow");
    }
    return new ImmutablePair<>(new PathInfoData(latency, forwardNodes), new PathInfoData(latency, reverseNodes));
}
Also used : StatementResult(org.neo4j.driver.v1.StatementResult) Statement(org.neo4j.driver.v1.Statement) PathNode(org.openkilda.messaging.info.event.PathNode) PathInfoData(org.openkilda.messaging.info.event.PathInfoData) ImmutablePair(org.openkilda.messaging.model.ImmutablePair) Relationship(org.neo4j.driver.v1.types.Relationship) Record(org.neo4j.driver.v1.Record) NoSuchRecordException(org.neo4j.driver.v1.exceptions.NoSuchRecordException) Session(org.neo4j.driver.v1.Session)

Aggregations

Test (org.junit.Test)72 Record (org.orcid.jaxb.model.record_v2.Record)62 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)25 Person (org.orcid.jaxb.model.record_v2.Person)22 Email (org.orcid.jaxb.model.record_v2.Email)20 Record (nikita.model.noark5.v4.Record)19 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)19 Address (org.orcid.jaxb.model.record_v2.Address)19 Name (org.orcid.jaxb.model.record_v2.Name)19 OtherName (org.orcid.jaxb.model.record_v2.OtherName)19 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)19 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)18 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)18 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)18 Keyword (org.orcid.jaxb.model.record_v2.Keyword)18 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)18 Record (org.neo4j.driver.v1.Record)17 Emails (org.orcid.jaxb.model.record_v2.Emails)17 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)16 Addresses (org.orcid.jaxb.model.record_v2.Addresses)16