@Test public void testConvertLiteral_nullDataType() { final Literal literal = mock(SimpleLiteral.class); final String expectedData = "Ice Cream"; when(literal.getLabel()).thenReturn(expectedData); when(literal.stringValue()).thenReturn(expectedData); when(literal.getDatatype()).thenReturn(null); final RyaType ryaType = RdfToRyaConversions.convertLiteral(literal); final RyaType expected = new RyaType(XMLSchema.STRING, expectedData); assertEquals(expected, ryaType); assertNull(ryaType.getLanguage()); }
public static RyaType convertLiteral(final Literal literal) { if (literal == null) { return null; } if (literal.getDatatype() != null) { if (Literals.isLanguageLiteral(literal)) { final String language = literal.getLanguage().get(); if (Literals.isValidLanguageTag(language)) { return new RyaType(literal.getDatatype(), literal.stringValue(), language); } else { log.warn("Invalid language (" + LogUtils.clean(language) + ") found in Literal. Defaulting to: " + UNDETERMINED_LANGUAGE); return new RyaType(literal.getDatatype(), literal.stringValue(), UNDETERMINED_LANGUAGE); } } return new RyaType(literal.getDatatype(), literal.stringValue()); } return new RyaType(literal.stringValue()); }
RdfToRyaConversions { public static RyaType convertLiteral(final Literal literal) { if (literal == null) { return null; } if (literal.getDatatype() != null) { if (Literals.isLanguageLiteral(literal)) { final String language = literal.getLanguage().get(); if (Literals.isValidLanguageTag(language)) { return new RyaType(literal.getDatatype(), literal.stringValue(), language); } else { log.warn("Invalid language (" + LogUtils.clean(language) + ") found in Literal. Defaulting to: " + UNDETERMINED_LANGUAGE); return new RyaType(literal.getDatatype(), literal.stringValue(), UNDETERMINED_LANGUAGE); } } return new RyaType(literal.getDatatype(), literal.stringValue()); } return new RyaType(literal.stringValue()); } }
RdfToRyaConversions { public static RyaType convertLiteral(final Literal literal) { if (literal == null) { return null; } if (literal.getDatatype() != null) { if (Literals.isLanguageLiteral(literal)) { final String language = literal.getLanguage().get(); if (Literals.isValidLanguageTag(language)) { return new RyaType(literal.getDatatype(), literal.stringValue(), language); } else { log.warn("Invalid language (" + LogUtils.clean(language) + ") found in Literal. Defaulting to: " + UNDETERMINED_LANGUAGE); return new RyaType(literal.getDatatype(), literal.stringValue(), UNDETERMINED_LANGUAGE); } } return new RyaType(literal.getDatatype(), literal.stringValue()); } return new RyaType(literal.stringValue()); }  }
RdfToRyaConversions { public static RyaType convertLiteral(final Literal literal) { if (literal == null) { return null; } if (literal.getDatatype() != null) { if (Literals.isLanguageLiteral(literal)) { final String language = literal.getLanguage().get(); if (Literals.isValidLanguageTag(language)) { return new RyaType(literal.getDatatype(), literal.stringValue(), language); } else { log.warn("Invalid language (" + LogUtils.clean(language) + ") found in Literal. Defaulting to: " + UNDETERMINED_LANGUAGE); return new RyaType(literal.getDatatype(), literal.stringValue(), UNDETERMINED_LANGUAGE); } } return new RyaType(literal.getDatatype(), literal.stringValue()); } return new RyaType(literal.stringValue()); }  static RyaIRI convertIRI(final IRI iri); static RyaType convertLiteral(final Literal literal); static RyaType convertValue(final Value value); static RyaIRI convertResource(final Resource resource); static RyaStatement convertStatement(final Statement statement); }
RdfToRyaConversions { public static RyaType convertLiteral(final Literal literal) { if (literal == null) { return null; } if (literal.getDatatype() != null) { if (Literals.isLanguageLiteral(literal)) { final String language = literal.getLanguage().get(); if (Literals.isValidLanguageTag(language)) { return new RyaType(literal.getDatatype(), literal.stringValue(), language); } else { log.warn("Invalid language (" + LogUtils.clean(language) + ") found in Literal. Defaulting to: " + UNDETERMINED_LANGUAGE); return new RyaType(literal.getDatatype(), literal.stringValue(), UNDETERMINED_LANGUAGE); } } return new RyaType(literal.getDatatype(), literal.stringValue()); } return new RyaType(literal.stringValue()); }  static RyaIRI convertIRI(final IRI iri); static RyaType convertLiteral(final Literal literal); static RyaType convertValue(final Value value); static RyaIRI convertResource(final Resource resource); static RyaStatement convertStatement(final Statement statement);  }