use of nikita.model.noark5.v4.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");
}
use of nikita.model.noark5.v4.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);
}
use of nikita.model.noark5.v4.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);
}
use of nikita.model.noark5.v4.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);
}
use of nikita.model.noark5.v4.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));
}
Aggregations