当前位置: 首页>>代码示例>>Java>>正文


Java SimpleValueFactory类代码示例

本文整理汇总了Java中org.eclipse.rdf4j.model.impl.SimpleValueFactory的典型用法代码示例。如果您正苦于以下问题:Java SimpleValueFactory类的具体用法?Java SimpleValueFactory怎么用?Java SimpleValueFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SimpleValueFactory类属于org.eclipse.rdf4j.model.impl包,在下文中一共展示了SimpleValueFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: map_withClasses_appliesEveryClassToGeneratedSubject

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
@Test
public void map_withClasses_appliesEveryClassToGeneratedSubject() throws Exception {

	EvaluateExpression evaluator = null;
	SimpleValueFactory f = SimpleValueFactory.getInstance();
	IRI subjectIRI = f.createIRI("http://foo.bar/subjectIRI");

	when(subjectGenerator.apply(evaluator))
			.thenReturn(Optional.of(subjectIRI));

	Set<IRI> expectedClasses = 
		ImmutableSet.of(
			f.createIRI("http://www.none.invalid/foo"),
			f.createIRI("http://www.none.invalid/bar"),
			f.createIRI("http://www.none.invalid/baz")
		);

	Model model = new ModelBuilder().build();
	SubjectMapper s = new SubjectMapper(subjectGenerator, ImmutableSet.of(), expectedClasses, ImmutableSet.of());
	s.map(model, evaluator);

	expectedClasses.forEach(iri -> Assert.assertTrue(model.contains(subjectIRI, RDF.TYPE, iri)));
}
 
开发者ID:carml,项目名称:carml,代码行数:24,代码来源:SubjectMapperTest.java

示例2: map_withPredicateMappers_callsEachPredicateMapper

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
@Test
public void map_withPredicateMappers_callsEachPredicateMapper() throws Exception {
	SimpleValueFactory f = SimpleValueFactory.getInstance();
	IRI subjectIRI = f.createIRI("http://foo.bar/subjectIRI");

	Set<PredicateMapper> predicateMappers = ImmutableSet.of(
			mock(PredicateMapper.class),
			mock(PredicateMapper.class),
			mock(PredicateMapper.class),
			mock(PredicateMapper.class)
	);

	Model model = new ModelBuilder().build();
	EvaluateExpression evaluator = null;


	PredicateObjectMapper testSubject = new PredicateObjectMapper(ImmutableSet.of(), predicateMappers);
	testSubject.map(model, evaluator, subjectIRI, ImmutableSet.of());

	predicateMappers.forEach(mapper -> verify(mapper).map(model, evaluator, subjectIRI));
}
 
开发者ID:carml,项目名称:carml,代码行数:22,代码来源:PredicateObjectMapperTest.java

示例3: IriTermGenerator_withRelativeIRI_usesBaseIRI

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
@Test
public void IriTermGenerator_withRelativeIRI_usesBaseIRI() throws Exception {

	ValueFactory f = SimpleValueFactory.getInstance();

	String baseIri = "http://base.iri";
	TermGeneratorCreator tgc = new TermGeneratorCreator(f, baseIri, null, TemplateParser.build(), null);

	String ref = "ref";
	TermGenerator<Value> generator = tgc.getObjectGenerator(new ObjectMapImpl(ref, null, null, TermType.IRI, null, null, null, null));

	String relativeIriPart = "/relativeIriPortion";
	EvaluateExpression evaluator = Mockito.mock(EvaluateExpression.class);
	when(evaluator.apply(ref)).thenReturn(Optional.of(relativeIriPart));
	Optional<Value> result = generator.apply(evaluator);

	Assert.assertTrue(result.isPresent());
	Assert.assertTrue(result.get() instanceof IRI);
	Assert.assertEquals(result.get(), f.createIRI(baseIri + relativeIriPart));
}
 
开发者ID:carml,项目名称:carml,代码行数:21,代码来源:TermGeneratorCreatorTest.java

示例4: IriTermGenerator_withAbsoluteIRI_usesBaseIRI

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
@Test
public void IriTermGenerator_withAbsoluteIRI_usesBaseIRI() throws Exception {

	ValueFactory f = SimpleValueFactory.getInstance();

	String baseIri = "http://base.iri";
	TermGeneratorCreator tgc = new TermGeneratorCreator(f, baseIri, null, TemplateParser.build(), null);

	String ref = "ref";
	TermGenerator<Value> generator = tgc.getObjectGenerator(new ObjectMapImpl(ref, null, null, TermType.IRI, null, null, null, null));

	String absoluteIri = "http://foo.bar/absoluteIri";
	EvaluateExpression evaluator = Mockito.mock(EvaluateExpression.class);
	when(evaluator.apply(ref)).thenReturn(Optional.of(absoluteIri));
	Optional<Value> result = generator.apply(evaluator);

	Assert.assertTrue(result.isPresent());
	Assert.assertTrue(result.get() instanceof IRI);
	Assert.assertEquals(result.get(), f.createIRI(absoluteIri));
}
 
开发者ID:carml,项目名称:carml,代码行数:21,代码来源:TermGeneratorCreatorTest.java

示例5: IriTermGenerator_withFaultyIRI_throwsException

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
@Test
public void IriTermGenerator_withFaultyIRI_throwsException() throws Exception {

	ValueFactory f = SimpleValueFactory.getInstance();

	String baseIri = "?";
	TermGeneratorCreator tgc = new TermGeneratorCreator(f, baseIri, null, TemplateParser.build(), null);

	String ref = "ref";
	TermGenerator<Value> generator = tgc.getObjectGenerator(new ObjectMapImpl(ref, null, null, TermType.IRI, null, null, null, null));

	String relativeIriPart = "/relativeIriPortion";
	EvaluateExpression evaluator = Mockito.mock(EvaluateExpression.class);
	when(evaluator.apply(ref)).thenReturn(Optional.of(relativeIriPart));

	RuntimeException exception = null;
	try {
		generator.apply(evaluator);
		Assert.assertTrue("This code should be unreachable", false);
	} catch (RuntimeException e) {
		exception = e;
	}

	Assert.assertNotNull(exception);
	Assert.assertTrue(exception.getMessage().startsWith("data error: could not generate a valid iri"));
}
 
开发者ID:carml,项目名称:carml,代码行数:27,代码来源:TermGeneratorCreatorTest.java

示例6: filterSubjects_ReturnsResults_WhenFilterDoesMatch

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
@Test
public void filterSubjects_ReturnsResults_WhenFilterDoesMatch() {
  // Arrange
  Model model = new ModelBuilder().add("http://www.test.nl#subj", "http://www.test.nl#is",
      SimpleValueFactory.getInstance().createIRI("http://www.test.nl#obj1")).add(
          "http://www.test.nl#subj2", "http://www.test.nl#is",
          SimpleValueFactory.getInstance().createIRI("http://www.test.nl#obj1")).build();
  when(graphEntityContextMock.getModel()).thenReturn(model);

  Map<String, Object> vendorExtensions =
      Maps.newHashMap(ImmutableMap.of(OpenApiSpecificationExtensions.SUBJECT_FILTER,
          Maps.newHashMap(ImmutableMap.of(OpenApiSpecificationExtensions.SUBJECT_FILTER_PREDICATE,
              "http://www.test.nl#is", OpenApiSpecificationExtensions.SUBJECT_FILTER_OBJECT,
              "http://www.test.nl#obj1"))));
  when(propertyMock.getVendorExtensions()).thenReturn(vendorExtensions);
  // Act
  Set<Resource> results = mapper.getSubjects(propertyMock, graphEntityContextMock);
  // Assert
  assertThat(results, hasSize(is(2)));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:21,代码来源:AbstractSubjectFilterSchemaMapperTest.java

示例7: listObjects_NoDuplicates_WhenSubjectAndPropSimilar

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
@Test
public void listObjects_NoDuplicates_WhenSubjectAndPropSimilar() throws Exception {
  // Arrange
  RepositoryConnection repositoryConnection = mock(RepositoryConnection.class);
  when(repository.getConnection()).thenReturn(repositoryConnection);
  ValueFactory valueFactory = SimpleValueFactory.getInstance();
  when(repositoryConnection.getValueFactory()).thenReturn(valueFactory);
  RepositoryResult queryResult = mock(RepositoryResult.class);

  Model model =
      new ModelBuilder().add("http://www.test.nl#sub", "http://www.test.nl#pred", "test").build();
  when(queryResult.hasNext()).thenReturn(true).thenReturn(false);
  when(queryResult.next()).thenReturn(model.stream().findFirst().get());
  when(
      repositoryConnection.getStatements(any(), any(), isNull(), anyBoolean(), any())).thenReturn(
          queryResult);
  Value subject = SimpleValueFactory.getInstance().createIRI("http://www.test.nl#test");
  Value prop = SimpleValueFactory.getInstance().createIRI("http://www.test.nl#test");
  // Act
  Collection<Value> values = backend.listObjects(subject, prop);
  // Assert
  assertThat(values, hasSize(1));
  assertThat(values.iterator().next().stringValue(), is("test"));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:25,代码来源:Rdf4jRepositoryBackendTest.java

示例8: listSubjects_ListOnlySubjects_InMixedModel

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
@Test
public void listSubjects_ListOnlySubjects_InMixedModel() throws Exception {
  // Arrange
  RepositoryConnection repositoryConnection = mock(RepositoryConnection.class);
  when(repository.getConnection()).thenReturn(repositoryConnection);
  ValueFactory valueFactory = SimpleValueFactory.getInstance();
  when(repositoryConnection.getValueFactory()).thenReturn(valueFactory);
  RepositoryResult queryResult = mock(RepositoryResult.class);

  Model model =
      new ModelBuilder().add("http://www.test.nl#sub", "http://www.test.nl#pred", "test").build();
  when(queryResult.hasNext()).thenReturn(true).thenReturn(false);
  when(queryResult.next()).thenReturn(model.stream().findFirst().get());
  when(
      repositoryConnection.getStatements(isNull(), any(), any(), anyBoolean(), any())).thenReturn(
          queryResult);
  Value subject = SimpleValueFactory.getInstance().createIRI("http://www.test.nl#test");
  Value prop = SimpleValueFactory.getInstance().createIRI("http://www.test.nl#test");
  // Act
  Collection<Value> values = backend.listSubjects(subject, prop);
  // Assert
  assertThat(values, hasSize(1));
  assertThat(values.iterator().next(),
      is(SimpleValueFactory.getInstance().createIRI("http://www.test.nl#sub")));
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:26,代码来源:Rdf4jRepositoryBackendTest.java

示例9: listSubjects_ThrowsExeption_QueryingRepositoryFailed

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
@Test
public void listSubjects_ThrowsExeption_QueryingRepositoryFailed() {
  // Assert
  thrown.expect(Rdf4jBackendRuntimeException.class);
  thrown.expectMessage("Error while querying RDF4J repository.");
  RepositoryConnection repositoryConnection = mock(RepositoryConnection.class);

  // Arrange
  when(repository.getConnection()).thenReturn(repositoryConnection);
  Exception dummy = new Exception("x");

  doThrow(new RepositoryLockedException("a", "b", "c", dummy)).when(repositoryConnection).begin();
  Value object = SimpleValueFactory.getInstance().createIRI("http://www.test.nl#test");
  Value prop = SimpleValueFactory.getInstance().createIRI("http://www.test.nl#test");

  // Act
  backend.listSubjects(prop, object);
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:19,代码来源:Rdf4jRepositoryBackendTest.java

示例10: listObjects_ThrowsExeption_ForIllegalSubject

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
@Test
public void listObjects_ThrowsExeption_ForIllegalSubject() {
  // Assert
  thrown.expect(IllegalArgumentException.class);
  thrown.expectMessage("Subject needs to be a URI or blank node, property a URI node"
      + " (types: [subject: URI, property: bNode]).");

  // Arrange
  RepositoryConnection repositoryConnection = mock(RepositoryConnection.class);
  when(repository.getConnection()).thenReturn(repositoryConnection);
  Value subject = SimpleValueFactory.getInstance().createIRI("http://www.test.nl#test");
  Value prop = SimpleValueFactory.getInstance().createBNode();

  // Act
  backend.listObjects(subject, prop);
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:17,代码来源:Rdf4jRepositoryBackendTest.java

示例11: listObjects_ThrowsExeption_QueryingRepositoryFailed

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
@Test
public void listObjects_ThrowsExeption_QueryingRepositoryFailed() {
  // Assert
  thrown.expect(Rdf4jBackendRuntimeException.class);
  thrown.expectMessage("Error while querying RDF4J repository.");

  // Arrange
  RepositoryConnection repositoryConnection = mock(RepositoryConnection.class);

  when(repository.getConnection()).thenReturn(repositoryConnection);
  Exception dummy = new Exception("x");

  doThrow(new RepositoryLockedException("a", "b", "c", dummy)).when(repositoryConnection).begin();
  Value subject = SimpleValueFactory.getInstance().createIRI("http://www.test.nl#test");
  Value prop = SimpleValueFactory.getInstance().createIRI("http://www.test.nl#test");
  // Act
  backend.listObjects(subject, prop);
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:19,代码来源:Rdf4jRepositoryBackendTest.java

示例12: setUp

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
@Before
public void setUp() {
  SimpleValueFactory valueFactory = SimpleValueFactory.getInstance();

  parameter = new StringTermParameter(valueFactory.createIRI("http://parameter-iri"),
      "parameter-name", true);
  parameter2 = new StringTermParameter(valueFactory.createIRI("http://parameter2-iri"),
      "parameter2-name", true);

  product = new TestInformationProduct(DBEERPEDIA.ORIGIN_INFORMATION_PRODUCT,
      DBEERPEDIA.BREWERIES_LABEL.stringValue(), ResultType.GRAPH,
      ImmutableList.of(parameter, parameter2), templateProcessorMock);

  mapper = new RequestParameterMapper();

  requestParameters = new RequestParameters();
  MultivaluedMap<String, String> mvMap = new MultivaluedHashMap<>();
  mvMap.put("param1", ImmutableList.of("value", "valueB"));
  mvMap.put("param2", ImmutableList.of("value2"));
  requestParameters.putAll(mvMap);
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:22,代码来源:RequestParameterMapperTest.java

示例13: loadResources_ThrowException_WithUnknownParameterMapper

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
@Test
public void loadResources_ThrowException_WithUnknownParameterMapper() {
  // Assert
  thrown.expect(ConfigurationException.class);

  // Arrange
  ValueFactory valueFactory = SimpleValueFactory.getInstance();
  final IRI unknownParameterMapper =
      valueFactory.createIRI("http://dotwebstack.org/def/elmo", "UnknownParameterMapper");

  when(graphQuery.evaluate()).thenReturn(new IteratingGraphQueryResult(ImmutableMap.of(),
      ImmutableList.of(
          valueFactory.createStatement(DBEERPEDIA.SUBJECT_FROM_URL, RDF.TYPE,
              unknownParameterMapper),
          valueFactory.createStatement(DBEERPEDIA.SUBJECT_FROM_URL, ELMO.SOURCE_PROP,
              HTTP.REQUEST_URI),
          valueFactory.createStatement(DBEERPEDIA.SUBJECT_FROM_URL, ELMO.TARGET_PROP,
              DBEERPEDIA.SUBJECT_PARAMETER))));

  // Act
  parameterMapperResourceProvider.loadResources();
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:23,代码来源:ParameterMapperResourceProviderTest.java

示例14: setUp

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
@Before
public void setUp() {
  // Arrange
  SimpleValueFactory valueFactory = SimpleValueFactory.getInstance();

  requiredParameter = new StringTermParameter(
      valueFactory.createIRI("http://required-parameter-iri"), "required-parameter-name", true);
  optionalParameter = new StringTermParameter(
      valueFactory.createIRI("http://optional-parameter-iri"), "optional-parameter-name", false);

  product = new TestInformationProduct(DBEERPEDIA.ORIGIN_INFORMATION_PRODUCT,
      DBEERPEDIA.BREWERIES_LABEL.stringValue(), ResultType.GRAPH,
      ImmutableList.of(requiredParameter, optionalParameter), templateProcessorMock);

  representationRequestParameterMapper = new RepresentationRequestParameterMapper();

  uriInfoMock = mock(UriInfo.class);
  when(contextMock.getUriInfo()).thenReturn(uriInfoMock);

}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:21,代码来源:RepresentationRequestParameterMapperTest.java

示例15: convertValue

import org.eclipse.rdf4j.model.impl.SimpleValueFactory; //导入依赖的package包/类
public Value convertValue(Object object) {
  if (object instanceof Value) {
    return (Value) object;
  }

  ValueFactory valueFactory = SimpleValueFactory.getInstance();
  if (object instanceof String) {
    return valueFactory.createLiteral((String) object);
  }
  if (object instanceof Integer) {
    return valueFactory.createLiteral((Integer) object);
  }
  if (object instanceof Double) {
    return valueFactory.createLiteral((Double) object);
  }

  throw new NotSupportedException("Value is not supported: " + object.getClass());
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:19,代码来源:SparqlHttpStub.java


注:本文中的org.eclipse.rdf4j.model.impl.SimpleValueFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。