@Override public String toString(Date value) { return Literals. of(value). get(). toString(); }
@Override public String toString(XMLGregorianCalendar value) { return Literals. of(value). dateTime(). get(). toString(); }
private void checkNewTypeLiteral(Object value) { for(URI datatype:Datatypes.temporalDatatypes()) { LOGGER.debug("Trying typed literal creation using {} ({}) with {}...",value,value.getClass().getName(),datatype); Literal<?> literal=Literals.newTypedLiteral(value, datatype); LOGGER.debug("Got: {}",literal); assertThat( temporalAssertionMessage(datatype, value), literal,instanceOf(DateTimeLiteral.class)); assertThat(((DateTimeLiteral)literal).get(),equalTo(this.dateTime.get())); } }
private void checkNewLiteral(URI datatype, Object value) { LOGGER.debug("Trying literal creation using temporal value {} ({})...",value,value.getClass().getName()); Literal<?> literal=Literals.newLiteral(value); LOGGER.debug("Got: {}",literal); assertThat( temporalAssertionMessage(value), literal,instanceOf(DateTimeLiteral.class)); assertThat(((DateTimeLiteral)literal).type(),equalTo(datatype)); assertThat(((DateTimeLiteral)literal).get(),equalTo(this.dateTime.get())); }
@Test public void testCreationFromXMLGregorianCalendar$customTimeZone() { XMLGregorianCalendar xgc = xmlGregorianCalendar(); TimeZone timeZone = anotherTimeZone(this.dateTime.get()); DateTimeLiteral dateTimeLiteral= Literals. of(xgc). withTimeZone(timeZone). dateTime(); assertThat(this.dateTime,not(equalTo(dateTimeLiteral))); assertThat(this.dateTime.get().compareTo(dateTimeLiteral.get()),not(equalTo(0))); }
@Test public void testNewTypeLiteral$temporal$string() { checkNewTypeLiteral(this.dateTime.get().toString()); }
@Test public void testNewLiteral$temporal$dateTime() { checkNewLiteral(this.dateTime.get()); }
@Test public void testNewTypeLiteral$temporal$dateTime() { checkNewTypeLiteral(this.dateTime.get()); }
@Test public void testCreationFromXMLGregorianCalendar$customDefaults() throws DatatypeConfigurationException { XMLGregorianCalendar xgc = xmlGregorianCalendar(); XMLGregorianCalendar nxgc = DatatypeFactory. newInstance(). newXMLGregorianCalendar( new GregorianCalendar(anotherTimeZone(this.dateTime.get()))); DateTimeLiteral dateTimeLiteral= Literals. of(xgc). withDefaults(nxgc). dateTime(); assertThat(this.dateTime,equalTo(dateTimeLiteral)); }
private XMLGregorianCalendar xmlGregorianCalendar() { return TimeUtils. newInstance(). from(this.dateTime.get()). toXMLGregorianCalendar(); }
@Test public void testNewLiteral$temporal$sqlDate() { checkNewLiteral( Datatypes.DATE, TimeUtils. newInstance(). from(this.dateTime.get()). toSqlDate()); }
@Test public void testNewTypeLiteral$temporal$xmlGregorianCalendar() { checkNewTypeLiteral( TimeUtils. newInstance(). from(this.dateTime.get()). toXMLGregorianCalendar()); }
@Test public void testNewTypeLiteral$temporal$date() { checkNewTypeLiteral( TimeUtils. newInstance(). from(this.dateTime.get()). toDate()); }
@Test public void testNewTypeLiteral$temporal$sqlTime() { checkNewTypeLiteral( TimeUtils. newInstance(). from(this.dateTime.get()). toSqlTime()); }
@Test public void testNewLiteral$temporal$sqlTime() { checkNewLiteral( Datatypes.TIME, TimeUtils. newInstance(). from(this.dateTime.get()). toSqlTime()); }
@Test public void testNewLiteral$temporal$gregorianCalendar() { checkNewLiteral( TimeUtils. newInstance(). from(this.dateTime.get()). toGregorianCalendar()); }
@Test public void testNewTypeLiteral$temporal$sqlDate() { checkNewTypeLiteral( TimeUtils. newInstance(). from(this.dateTime.get()). toSqlDate()); }
@Test public void testNewLiteral$temporal$date() { checkNewLiteral( TimeUtils. newInstance(). from(this.dateTime.get()). toDate()); }
@Test public void testNewLiteral$temporal$xmlGregorianCalendar() { checkNewLiteral( TimeUtils. newInstance(). from(this.dateTime.get()). toXMLGregorianCalendar()); }
@Test public void testNewTypeLiteral$temporal$gregorianCalendar() { checkNewTypeLiteral( TimeUtils. newInstance(). from(this.dateTime.get()). toGregorianCalendar()); }