當前位置: 首頁>>代碼示例>>Java>>正文


Java Suffix類代碼示例

本文整理匯總了Java中org.apache.olingo.commons.api.data.ContextURL.Suffix的典型用法代碼示例。如果您正苦於以下問題:Java Suffix類的具體用法?Java Suffix怎麽用?Java Suffix使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Suffix類屬於org.apache.olingo.commons.api.data.ContextURL包,在下文中一共展示了Suffix類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getContextUrl

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
private ODataSerializerOptions getContextUrl( final org.apache.olingo.commons.api.edm.EdmEntitySet entitySet,
        final UriInfo uriInfo,
        final ODataFormat format,
        final ODataSerializer serializer,
        final boolean isSingleEntity,
        final String path) throws SerializerException {
    ContextURL contextUrl = ContextURL.with().entitySetOrSingletonOrType(path)
            .selectList(serializer.buildContextURLSelectList(entitySet, uriInfo.getExpandOption(), uriInfo.getSelectOption()))
            .suffix(isSingleEntity ? Suffix.ENTITY : null)
            .build();
    return ODataSerializerOptions.with()
        .contextURL(format == ODataFormat.JSON_NO_METADATA ? null : contextUrl)
        .count(uriInfo.getCountOption())
        .expand(uriInfo.getExpandOption()).select(uriInfo.getSelectOption())
        .build();
}
 
開發者ID:kenweezy,項目名稱:teiid,代碼行數:17,代碼來源:TeiidProcessor.java

示例2: entityAllPrimAllNull

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
@Test
public void entityAllPrimAllNull() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
  entity.getProperties().retainAll(Collections.singletonList(entity.getProperties().get(0)));
  final String resultString = IOUtils.toString(serializer.entity(metadata, edmEntitySet.getEntityType(),
      entity,
      EntitySerializerOptions.with()
          .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
          .build()).getContent());
  final String expectedResult = "{\"@odata.context\":\"$metadata#ESAllPrim/$entity\","
      + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
      + "\"PropertyInt16\":32767,"
      + "\"PropertyString\":null,\"PropertyBoolean\":null,"
      + "\"PropertyByte\":null,\"PropertySByte\":null,"
      + "\"PropertyInt32\":null,\"PropertyInt64\":null,"
      + "\"PropertySingle\":null,\"PropertyDouble\":null,\"PropertyDecimal\":null,"
      + "\"PropertyBinary\":null,"
      + "\"PropertyDate\":null,\"PropertyDateTimeOffset\":null,\"PropertyDuration\":null,"
      + "\"PropertyGuid\":null,\"PropertyTimeOfDay\":null}";
  Assert.assertEquals(expectedResult, resultString);
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:23,代碼來源:ODataJsonSerializerTest.java

示例3: entityWrongData

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
@Test
public void entityWrongData() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
  entity.getProperties().get(0).setValue(ValueType.PRIMITIVE, false);
  try {
    serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
        EntitySerializerOptions.with()
            .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
            .build());
    Assert.fail("Expected exception not thrown!");
  } catch (final SerializerException e) {
    Assert.assertEquals(SerializerException.MessageKeys.WRONG_PROPERTY_VALUE, e.getMessageKey());
    final String message = e.getLocalizedMessage();
    Assert.assertThat(message, CoreMatchers.containsString("PropertyInt16"));
    Assert.assertThat(message, CoreMatchers.containsString("false"));
  }
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:19,代碼來源:ODataJsonSerializerTest.java

示例4: entityMixPrimCollComp

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
@Test
public void entityMixPrimCollComp() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixPrimCollComp");
  final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
  InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
      EntitySerializerOptions.with()
          .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
          .build()).getContent();
  final String resultString = IOUtils.toString(result);
  final String expectedResult = "{"
      + "\"@odata.context\":\"$metadata#ESMixPrimCollComp/$entity\","
      + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
      + "\"PropertyInt16\":32767,"
      + "\"CollPropertyString\":"
      + "[\"[email protected]\",\"[email protected]\",\"[email protected]\"],"
      + "\"PropertyComp\":{\"PropertyInt16\":111,\"PropertyString\":\"TEST A\"},"
      + "\"CollPropertyComp\":["
      + "{\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"},"
      + "{\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},"
      + "{\"@odata.type\":\"#olingo.odata.test1.CTBase\",\"PropertyInt16\":789,"
      + "\"PropertyString\":\"TEST 3\",\"AdditionalPropString\":\"ADD TEST\"}]}";
  Assert.assertEquals(expectedResult, resultString);
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:24,代碼來源:ODataJsonSerializerTest.java

示例5: derivedEntityESCompCollDerived

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
@Test
public void derivedEntityESCompCollDerived() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCompCollDerived");
  final Entity entity = data.readAll(edmEntitySet).getEntities().get(1);
  InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
      EntitySerializerOptions.with()
          .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
          .build()).getContent();
  final String resultString = IOUtils.toString(result);
  final String expectedResult =  "{"
      + "\"@odata.context\":\"$metadata#ESCompCollDerived/$entity\","
      + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
      + "\"PropertyInt16\":12345,"
      + "\"PropertyCompAno\":{"
      + "\"@odata.type\":\"#olingo.odata.test1.CTBaseAno\","
      + "\"PropertyString\":\"Num111\","
      + "\"AdditionalPropString\":\"Test123\""
      + "},"
      + "\"CollPropertyCompAno\":["
      + "{\"@odata.type\":\"#olingo.odata.test1.CTBaseAno\","
      + "\"PropertyString\":\"TEST12345\","
      + "\"AdditionalPropString\":\"Additional12345\"},"
      + "{\"PropertyString\":\"TESTabcd\"}]}";
  Assert.assertEquals(expectedResult, resultString);
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:26,代碼來源:ODataJsonSerializerTest.java

示例6: deriveEntityWithNull

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
@Test
public void deriveEntityWithNull() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrimDerived");
  final Entity entity = data.readAll(edmEntitySet).getEntities().get(1);
 
  final ExpandOption expand = ExpandSelectMock.mockExpandOption(Collections.singletonList(
      ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETTwoPrimOne")));
  InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
      EntitySerializerOptions.with()
          .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
          .expand(expand)
          .build()).getContent();
  final String resultString = IOUtils.toString(result);
  final String expectedResult =   "{\"@odata.context\":\"$metadata#ESAllPrimDerived/$entity\","
      + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\",\"PropertyInt16\":-32768,"
      + "\"PropertyString\":\"Second Resource - negative values\","
      + "\"PropertyBoolean\":false,\"PropertyByte\":0,\"PropertySByte\":-128,"
      + "\"PropertyInt32\":-2147483648,\"PropertyInt64\":-9223372036854775808,"
      + "\"PropertySingle\":-1.79E8,\"PropertyDouble\":-179000.0,\"PropertyDecimal\":-34,"
      + "\"PropertyBinary\":\"ASNFZ4mrze8=\",\"PropertyDate\":\"2015-11-05\","
      + "\"PropertyDateTimeOffset\":\"2005-12-03T07:17:08Z\",\"PropertyDuration\":\"PT9S\","
      + "\"PropertyGuid\":\"76543201-23ab-cdef-0123-456789dddfff\","
      + "\"PropertyTimeOfDay\":\"23:49:14\",\"NavPropertyETTwoPrimOne\":null}";
  Assert.assertEquals(expectedResult, resultString);
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:26,代碼來源:ODataJsonSerializerTest.java

示例7: nullComplexValueButInDataMapAndNullCollectionsNotInDataMap

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
@Test
public void nullComplexValueButInDataMapAndNullCollectionsNotInDataMap() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMixEnumDefCollComp");
  Entity entity = new Entity();
  entity.setId(URI.create("id"));
  entity.addProperty(new Property(null, "PropertyEnumString", ValueType.ENUM, 6));
  entity.addProperty(new Property(null, "PropertyDefString", ValueType.PRIMITIVE, "Test"));
  entity.addProperty(new Property(null, "PropertyCompMixedEnumDef", ValueType.COMPLEX, null));
  final String resultString = IOUtils.toString(serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
      EntitySerializerOptions.with()
          .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
          .build()).getContent());
  Assert.assertEquals("{\"@odata.context\":\"$metadata#ESMixEnumDefCollComp/$entity\","
      + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
      + "\"PropertyEnumString\":\"String2,String3\","
      + "\"CollPropertyEnumString\":[],"
      + "\"PropertyDefString\":\"Test\","
      + "\"CollPropertyDefString\":[],"
      + "\"PropertyCompMixedEnumDef\":null,"
      + "\"CollPropertyCompMixedEnumDef\":[]}",
      resultString);
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:23,代碼來源:ODataJsonSerializerTest.java

示例8: entityMedia

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
@Test
public void entityMedia() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMedia");
  final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
  final String resultString = IOUtils.toString(serializer.entity(metadata, edmEntitySet.getEntityType(),
      entity,
      EntitySerializerOptions.with()
          .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
          .build()).getContent());
  final String expectedResult = "{\"@odata.context\":\"$metadata#ESMedia/$entity\","
      + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
      + "\"@odata.mediaEtag\":\"W/\\\"1\\\"\","
      + "\"@odata.mediaContentType\":\"image/svg+xml\","
      + "\"@odata.mediaEditLink\":\"ESMedia(1)/$value\","
      + "\"PropertyInt16\":1}";
  Assert.assertEquals(expectedResult, resultString);
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:18,代碼來源:ODataJsonSerializerTest.java

示例9: entityMediaWithMetadataFull

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
@Test
public void entityMediaWithMetadataFull() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESMedia");
  final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
  entity.setMediaETag("W/\\\"08D25949E3BFB7AB\\\"");
  InputStream result = serializerFullMetadata
      .entity(metadata, edmEntitySet.getEntityType(), entity,
          EntitySerializerOptions.with().contextURL(ContextURL.with()
              .entitySet(edmEntitySet).suffix(Suffix.ENTITY).build()).build())
      .getContent();
  final String resultString = IOUtils.toString(result);
  final String expectedResult = "{\"@odata.context\":\"$metadata#ESMedia/$entity\","
      + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
      + "\"@odata.mediaEtag\":\"W/\\\\\\\"08D25949E3BFB7AB\\\\\\\"\",\"@odata.mediaContentType\":\"image/svg+xml\","
      + "\"@odata.mediaEditLink\":\"ESMedia(1)/$value\","
      + "\"@odata.type\":\"#olingo.odata.test1.ETMedia\",\"@odata.id\":\"ESMedia(1)\","
      + "\"[email protected]\":\"#Int16\",\"PropertyInt16\":1}";
  Assert.assertEquals(expectedResult, resultString);
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:20,代碼來源:ODataJsonSerializerTest.java

示例10: selectAll

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
@Test
public void selectAll() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
  final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
  final SelectItem selectItem1 = ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyString");
  SelectItem selectItem2 = Mockito.mock(SelectItem.class);
  Mockito.when(selectItem2.isStar()).thenReturn(true);
  final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(selectItem1, selectItem2));
  InputStream result = serializer.entity(metadata, edmEntitySet.getEntityType(), entity,
      EntitySerializerOptions.with()
          .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
          .select(select)
          .build()).getContent();
  final String resultString = IOUtils.toString(result);
  final String expectedResult = "{\"@odata.context\":\"$metadata#ESTwoPrim/$entity\","
      + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
      + "\"PropertyInt16\":32766,\"PropertyString\":\"Test String1\"}";
  Assert.assertEquals(expectedResult, resultString);
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:20,代碼來源:ODataJsonSerializerTest.java

示例11: selectMissingId

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
@Test
public void selectMissingId() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  final EdmEntityType entityType = edmEntitySet.getEntityType();
  final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
  entity.setId(null);
  final SelectItem selectItem1 = ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyDate");
  final SelectItem selectItem2 = ExpandSelectMock.mockSelectItem(edmEntitySet, "PropertyBoolean");
  final SelectOption select = ExpandSelectMock.mockSelectOption(Arrays.asList(
      selectItem1, selectItem2, selectItem2));
    InputStream result = serializer.entity(metadata, entityType, entity,
          EntitySerializerOptions.with()
              .contextURL(ContextURL.with().entitySet(edmEntitySet)
                  .selectList(helper.buildContextURLSelectList(entityType, null, select))
                  .suffix(Suffix.ENTITY).build())
              .select(select)
              .build()).getContent();
        Assert.assertNotNull(result);   
        final String resultString = IOUtils.toString(result);
         Assert.assertEquals(  "{\"@odata.context\":\"$metadata#ESAllPrim(PropertyBoolean,PropertyDate)/$entity\","+
         "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\",\"@odata.id\":\"ESAllPrim(32767)\","+
          "\"PropertyBoolean\":true,\"PropertyDate\":\"2012-12-03\"}",
        resultString);   
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:25,代碼來源:ODataJsonSerializerTest.java

示例12: expandSelect

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
@Test
public void expandSelect() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
  final EdmEntityType entityType = edmEntitySet.getEntityType();
  final Entity entity = data.readAll(edmEntitySet).getEntities().get(3);
  final SelectOption select = ExpandSelectMock.mockSelectOption(Collections.singletonList(
      ExpandSelectMock.mockSelectItem(entityContainer.getEntitySet("ESAllPrim"), "PropertyDate")));
  ExpandItem expandItem = ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimOne");
  Mockito.when(expandItem.getSelectOption()).thenReturn(select);
  final ExpandOption expand = ExpandSelectMock.mockExpandOption(Collections.singletonList(expandItem));
  final String resultString = IOUtils.toString(serializer
      .entity(metadata, entityType, entity,
          EntitySerializerOptions.with()
              .contextURL(ContextURL.with().entitySet(edmEntitySet)
                  .selectList(helper.buildContextURLSelectList(entityType, expand, select))
                  .suffix(Suffix.ENTITY).build())
              .expand(expand)
              .build()).getContent());
  Assert.assertEquals("{"
      + "\"@odata.context\":\"$metadata#ESTwoPrim(NavPropertyETAllPrimOne(PropertyDate))/$entity\","
      + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
      + "\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\","
      + "\"NavPropertyETAllPrimOne\":{\"@odata.id\":\"ESAllPrim(32767)\",\"PropertyDate\":\"2012-12-03\"}}",
      resultString);
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:26,代碼來源:ODataJsonSerializerTest.java

示例13: entityCollectionReference

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
@Test
public void entityCollectionReference() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  final EntityCollection entityCollection = data.readAll(edmEntitySet);

  final SerializerResult serializerResult = serializer.referenceCollection(metadata,
      edmEntitySet,
      entityCollection,
      ReferenceCollectionSerializerOptions.with()
          .contextURL(ContextURL.with().asCollection().suffix(Suffix.REFERENCE).build())
          .build());

  final String resultString = IOUtils.toString(serializerResult.getContent());

  Assert.assertEquals("{\"@odata.context\":\"$metadata#Collection($ref)\","
      + "\"value\":[{\"@odata.id\":\"ESAllPrim(32767)\"},"
      + "{\"@odata.id\":\"ESAllPrim(-32768)\"},"
      + "{\"@odata.id\":\"ESAllPrim(0)\"}]}",
      resultString);
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:21,代碼來源:ODataJsonSerializerTest.java

示例14: entityCollectionReferenceEmpty

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
@Test
public void entityCollectionReferenceEmpty() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
  final EntityCollection entityCollection = new EntityCollection();

  final SerializerResult serializerResult = serializer.referenceCollection(metadata,
      edmEntitySet, entityCollection,
      ReferenceCollectionSerializerOptions.with()
          .contextURL(ContextURL.with().asCollection().suffix(Suffix.REFERENCE).build())
          .build());

  final String resultString = IOUtils.toString(serializerResult.getContent());

  Assert.assertEquals("{\"@odata.context\":\"$metadata#Collection($ref)\","
      + "\"value\":[]}", resultString);
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:17,代碼來源:ODataJsonSerializerTest.java

示例15: entityESKeyNavContFullMetadata

import org.apache.olingo.commons.api.data.ContextURL.Suffix; //導入依賴的package包/類
@Test
public void entityESKeyNavContFullMetadata() throws Exception {
  final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESKeyNavCont");
  final Entity entity = data.readAll(edmEntitySet).getEntities().get(0);
  InputStream result = serializerFullMetadata.entity(metadata, edmEntitySet.getEntityType(), entity,
      EntitySerializerOptions.with()
          .contextURL(ContextURL.with().entitySet(edmEntitySet).suffix(Suffix.ENTITY).build())
          .build()).getContent();
  final String resultString = IOUtils.toString(result);
  final String expected = "{\"@odata.context\":\"$metadata#ESKeyNavCont/$entity\","
      + "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\",\"@odata.type\":"
      + "\"#olingo.odata.test1.ETKeyNavCont\",\"@odata.id\":\"ESKeyNavCont(32766)\","
      + "\"[email protected]\":\"#Int16\",\"PropertyInt16\":32766,"
      + "\"PropertyString\":\"Test String1\",\"PropertyCompNavCont\":"
      + "{\"@odata.type\":\"#olingo.odata.test1.CTNavCont\"}}";        

  Assert.assertEquals(expected, resultString);
}
 
開發者ID:apache,項目名稱:olingo-odata4,代碼行數:19,代碼來源:ODataJsonSerializerTest.java


注:本文中的org.apache.olingo.commons.api.data.ContextURL.Suffix類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。