public TProperty apply(OEntity input) { return input.getProperty(propName, propClass).getValue(); } };
@Override public boolean apply(OEntity input) { Object pv = input.getProperty(propName).getValue(); return (value == null) ? pv == null : value.equals(pv); } };
@Override public boolean apply(OEntity input) { Object pv = input.getProperty(propName).getValue(); return (value == null) ? pv == null : value.equals(pv); } };
private void run(String[] args) { String[] datamarketCreds = args.length > 0 ? args : System.getenv("DATAMARKET").split(":"); String url = "https://api.datamarket.azure.com/Data.ashx/UnitedNations/MDG/"; ODataConsumer c = ODataConsumers.newBuilder(url) .setClientBehaviors(OClientBehaviors.basicAuth("accountKey", datamarketCreds[0])) .build(); OEntity firstDataSeries = c.getEntities("DataSeries").top(1).execute().first(); String filter = String.format("DataSeriesId eq '%s'", firstDataSeries.getProperty("Id").getValue()); reportEntities(firstDataSeries.getProperty("Name", String.class).getValue(), c.getEntities("Values").filter(filter).top(10).execute()); }
protected static void reportEntity(String caption, OEntity entity) { report(caption); if (entity.getEntityTag() != null) report(" ETag: %s", entity.getEntityTag()); for (OProperty<?> p : entity.getProperties()) { Object v = p.getValue(); if (p.getType().equals(EdmSimpleType.BINARY) && v != null) v = org.odata4j.repack.org.apache.commons.codec.binary.Base64.encodeBase64String((byte[]) v).trim(); report(" %s: %s", p.getName(), v); } }
/** * ToがなくてToRelationがある場合にDcCoreExceptionが発生しないこと. */ @Test public final void ToがなくてToRelationがある場合にDcCoreExceptionが発生しないこと() { String to = (String) OProperties.null_(SentMessage.P_TO.getName(), EdmSimpleType.STRING).getValue(); String toRelation = "http://example.com/toRelation"; MessageODataResource.validateToAndToRelation(to, toRelation); }
/** * Typeが関係登録依頼でRequestRelationがない場合にDcCoreExceptionが発生すること. */ @Test(expected = DcCoreException.class) public final void Typeが関係登録依頼でRequestRelationがない場合にDcCoreExceptionが発生すること() { String type = ReceivedMessage.TYPE_REQ_RELATION_BUILD; String requestRelation = (String) OProperties.null_( SentMessage.P_REQUEST_RELATION.getName(), EdmSimpleType.STRING).getValue(); String requestRelationTarget = "http://example.com/reqRelation"; MessageODataResource.validateReqRelation(type, requestRelation, requestRelationTarget); }
/** * ToがあってToRelationがない場合にDcCoreExceptionが発生しないこと. */ @Test public final void ToがあってToRelationがない場合にDcCoreExceptionが発生しないこと() { String to = "http://example.com/toAddress"; String toRelation = (String) OProperties.null_(SentMessage.P_TO_RELATION.getName(), EdmSimpleType.STRING).getValue(); MessageODataResource.validateToAndToRelation(to, toRelation); }
/** * Typeが関係登録依頼でRequestRelationTargetがない場合にDcCoreExceptionが発生すること. */ @Test(expected = DcCoreException.class) public final void Typeが関係登録依頼でRequestRelationTargetがない場合にDcCoreExceptionが発生すること() { String type = ReceivedMessage.TYPE_REQ_RELATION_BUILD; String requestRelation = "http://example.com/reqRelation"; String requestRelationTarget = (String) OProperties.null_( SentMessage.P_REQUEST_RELATION_TARGET.getName(), EdmSimpleType.STRING).getValue(); MessageODataResource.validateReqRelation(type, requestRelation, requestRelationTarget); }
/** * MulticastToがNullの場合にNullOPropertyが返却されること. */ @Test public final void MulticastToがNullの場合にNullOPropertyが返却されること() { OProperty<?> expected = OProperties.null_(ReceivedMessage.P_MULTICAST_TO.getName(), EdmSimpleType.STRING); OProperty<?> result = this.setDefaultValue(ReceivedMessage.P_MULTICAST_TO.build(), ReceivedMessage.P_MULTICAST_TO.getName(), OProperties.string(ReceivedMessage.P_MULTICAST_TO.getName(), AbstractCase.STRING_LENGTH_129)); assertEquals(expected.getValue(), result.getValue()); }
/** * ToがNullの場合にNullOPropertyが返却されること. */ @Test public final void ToがNullの場合にNullOPropertyが返却されること() { OProperty<?> expected = OProperties.null_(SentMessage.P_TO.getName(), EdmSimpleType.STRING); OProperty<?> result = this.setDefaultValue(SentMessage.P_TO.build(), SentMessage.P_TO.getName(), OProperties.string(SentMessage.P_TO.getName(), AbstractCase.STRING_LENGTH_129)); assertEquals(expected.getValue(), result.getValue()); }
/** * ToRelationがnullの場合にNullOPropertyが返却されること. */ @Test public final void ToRelationがnullの場合にNullOPropertyが返却されること() { OProperty<?> expected = OProperties.null_(SentMessage.P_TO_RELATION.getName(), EdmSimpleType.STRING); OProperty<?> result = this.setDefaultValue(SentMessage.P_TO_RELATION.build(), SentMessage.P_TO_RELATION.getName(), OProperties.string(SentMessage.P_TO_RELATION.getName(), "")); assertEquals(expected.getValue(), result.getValue()); }
/** * Typeがnullの場合にmessageが返却されること. */ @Test public final void Typeがnullの場合にmessageが返却されること() { OProperty<?> expected = OProperties.string(SentMessage.P_TYPE.getName(), "message"); OProperty<?> result = this.setDefaultValue(SentMessage.P_TYPE.build(), SentMessage.P_TYPE.getName(), OProperties.string(SentMessage.P_TYPE.getName(), "")); assertEquals(expected.getValue(), result.getValue()); }
/** * InReplyToがNullの場合にNullOPropertyが返却されること. */ @Test public final void InReplyToがNullの場合にNullOPropertyが返却されること() { OProperty<?> expected = OProperties.null_(ReceivedMessage.P_IN_REPLY_TO.getName(), EdmSimpleType.STRING); OProperty<?> result = this.setDefaultValue(ReceivedMessage.P_IN_REPLY_TO.build(), ReceivedMessage.P_IN_REPLY_TO.getName(), OProperties.string(ReceivedMessage.P_IN_REPLY_TO.getName(), "")); assertEquals(expected.getValue(), result.getValue()); }
/** * RequestRelationがNullの場合にNullOPropertyが返却されること. */ @Test public final void RequestRelationがNullの場合にNullOPropertyが返却されること() { OProperty<?> expected = OProperties.null_(ReceivedMessage.P_REQUEST_RELATION.getName(), EdmSimpleType.STRING); OProperty<?> result = this.setDefaultValue(ReceivedMessage.P_REQUEST_RELATION.build(), ReceivedMessage.P_REQUEST_RELATION.getName(), OProperties.string(ReceivedMessage.P_REQUEST_RELATION.getName(), AbstractCase.STRING_LENGTH_129)); assertEquals(expected.getValue(), result.getValue()); }
/** * Titleがnullの場合に空文字が返却されること. */ @Test public final void Titleがnullの場合に空文字が返却されること() { OProperty<?> expected = OProperties.string(SentMessage.P_TITLE.getName(), ""); OProperty<?> result = this.setDefaultValue(SentMessage.P_TITLE.build(), SentMessage.P_TITLE.getName(), OProperties.string(SentMessage.P_TITLE.getName(), "")); assertEquals(expected.getValue(), result.getValue()); }
/** * Bodyがnullの場合に空文字が返却されること. */ @Test public final void Bodyがnullの場合に空文字が返却されること() { OProperty<?> expected = OProperties.string(SentMessage.P_BODY.getName(), ""); OProperty<?> result = this.setDefaultValue(SentMessage.P_BODY.build(), SentMessage.P_BODY.getName(), OProperties.string(SentMessage.P_BODY.getName(), "")); assertEquals(expected.getValue(), result.getValue()); }
/** * RequestRelationがNullの場合にNullOPropertyが返却されること. */ @Test public final void RequestRelationがNullの場合にNullOPropertyが返却されること() { OProperty<?> expected = OProperties.null_(SentMessage.P_REQUEST_RELATION.getName(), EdmSimpleType.STRING); OProperty<?> result = this.setDefaultValue(SentMessage.P_REQUEST_RELATION.build(), SentMessage.P_REQUEST_RELATION.getName(), OProperties.string(SentMessage.P_REQUEST_RELATION.getName(), AbstractCase.STRING_LENGTH_129)); assertEquals(expected.getValue(), result.getValue()); }
/** * RequestRelationTargetがNullの場合にNullOPropertyが返却されること. */ @Test public final void RequestRelationTargetがNullの場合にNullOPropertyが返却されること() { OProperty<?> expected = OProperties.null_(SentMessage.P_REQUEST_RELATION_TARGET.getName(), EdmSimpleType.STRING); OProperty<?> result = this.setDefaultValue(SentMessage.P_REQUEST_RELATION_TARGET.build(), SentMessage.P_REQUEST_RELATION_TARGET.getName(), OProperties.string(SentMessage.P_REQUEST_RELATION_TARGET.getName(), AbstractCase.STRING_LENGTH_129)); assertEquals(expected.getValue(), result.getValue()); }
/** * RequestRelationTargetがNullの場合にNullOPropertyが返却されること. */ @Test public final void RequestRelationTargetがNullの場合にNullOPropertyが返却されること() { OProperty<?> expected = OProperties.null_(ReceivedMessage.P_REQUEST_RELATION_TARGET.getName(), EdmSimpleType.STRING); OProperty<?> result = this.setDefaultValue(ReceivedMessage.P_REQUEST_RELATION_TARGET.build(), ReceivedMessage.P_REQUEST_RELATION_TARGET.getName(), OProperties.string(ReceivedMessage.P_MULTICAST_TO.getName(), AbstractCase.STRING_LENGTH_129)); assertEquals(expected.getValue(), result.getValue()); }