Package org.apache.olingo.odata2.api.ep.entry

Examples of org.apache.olingo.odata2.api.ep.entry.ODataEntry


    assertNull(mediaMetadata.getEtag());
  }

  @Test
  public void readSimpleTeamEntry() throws Exception {
    ODataEntry result = prepareAndExecuteEntry(SIMPLE_ENTRY_TEAM, "Teams", DEFAULT_PROPERTIES);

    Map<String, Object> properties = result.getProperties();
    assertNotNull(properties);
    assertEquals("1", properties.get("Id"));
    assertEquals("Team 1", properties.get("Name"));
    assertEquals(Boolean.FALSE, properties.get("isScrumTeam"));
    assertNull(properties.get("nt_Employees"));

    List<String> associationUris = result.getMetadata().getAssociationUris("nt_Employees");
    assertEquals(1, associationUris.size());
    assertEquals("http://localhost:8080/ReferenceScenario.svc/Teams('1')/nt_Employees", associationUris.get(0));

    checkMediaDataInitial(result.getMediaMetadata());
  }
View Full Code Here


    checkMediaDataInitial(result.getMediaMetadata());
  }

  @Test
  public void readSimpleBuildingEntry() throws Exception {
    ODataEntry result = prepareAndExecuteEntry(SIMPLE_ENTRY_BUILDING, "Buildings", DEFAULT_PROPERTIES);
    // verify
    Map<String, Object> properties = result.getProperties();
    assertNotNull(properties);
    assertEquals("1", properties.get("Id"));
    assertEquals("Building 1", properties.get("Name"));
    assertNull(properties.get("Image"));
    assertNull(properties.get("nb_Rooms"));

    List<String> associationUris = result.getMetadata().getAssociationUris("nb_Rooms");
    assertEquals(1, associationUris.size());
    assertEquals("http://localhost:8080/ReferenceScenario.svc/Buildings('1')/nb_Rooms", associationUris.get(0));

    checkMediaDataInitial(result.getMediaMetadata());
  }
View Full Code Here

    checkMediaDataInitial(result.getMediaMetadata());
  }

  @Test
  public void readSimpleBuildingEntryWithoutD() throws Exception {
    ODataEntry result = prepareAndExecuteEntry(SIMPLE_ENTRY_BUILDING_WITHOUT_D, "Buildings", DEFAULT_PROPERTIES);
    // verify
    Map<String, Object> properties = result.getProperties();
    assertNotNull(properties);
    assertEquals("1", properties.get("Id"));
    assertEquals("Building 1", properties.get("Name"));
    assertNull(properties.get("Image"));
    assertNull(properties.get("nb_Rooms"));

    List<String> associationUris = result.getMetadata().getAssociationUris("nb_Rooms");
    assertEquals(1, associationUris.size());
    assertEquals("http://localhost:8080/ReferenceScenario.svc/Buildings('1')/nb_Rooms", associationUris.get(0));

    checkMediaDataInitial(result.getMediaMetadata());
  }
View Full Code Here

  }

  @Test
  public void readMinimalEntry() throws Exception {
    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams");
    final ODataEntry result =
        new JsonEntityConsumer().readEntry(entitySet, createContentAsStream("{\"Id\":\"99\"}"), DEFAULT_PROPERTIES);

    final Map<String, Object> properties = result.getProperties();
    assertNotNull(properties);
    assertEquals(1, properties.size());
    assertEquals("99", properties.get("Id"));

    assertTrue(result.getMetadata().getAssociationUris("nt_Employees").isEmpty());
    checkMediaDataInitial(result.getMediaMetadata());
  }
View Full Code Here

  public void readEntryWithNullProperty() throws Exception {
    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
    final String content = "{\"Id\":\"99\",\"Seats\":null}";

    for (final boolean merge : new boolean[] { false, true }) {
      final ODataEntry result = new JsonEntityConsumer().readEntry(entitySet, createContentAsStream(content),
          EntityProviderReadProperties.init().mergeSemantic(merge).build());

      final Map<String, Object> properties = result.getProperties();
      assertNotNull(properties);
      assertEquals(2, properties.size());
      assertEquals("99", properties.get("Id"));
      assertTrue(properties.containsKey("Seats"));
      assertNull(properties.get("Seats"));

      assertTrue(result.getMetadata().getAssociationUris("nr_Employees").isEmpty());
      checkMediaDataInitial(result.getMediaMetadata());
    }
  }
View Full Code Here

    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams");
    InputStream contentBody = createContentAsStream(
        "{\"__metadata\":{\"properties\":{\"nt_Employees\":{\"associationuri\":"
            + "\"http://some.host.com/service.root/Teams('1')/$links/nt_Employees\"}}},"
            + "\"Id\":\"1\"}");
    ODataEntry result = new JsonEntityConsumer().readEntry(entitySet, contentBody, DEFAULT_PROPERTIES);
    checkMediaDataInitial(result.getMediaMetadata());
  }
View Full Code Here

      final JPAEntity virtualJPAEntity = new JPAEntity(oDataEntityType, oDataEntitySet, oDataJPAContext);
      Object jpaEntity = null;

      if (content != null) {
        final ODataEntityParser oDataEntityParser = new ODataEntityParser(oDataJPAContext);
        final ODataEntry oDataEntry =
            oDataEntityParser.parseEntry(oDataEntitySet, content, requestedContentType, false);
        virtualJPAEntity.create(oDataEntry);
      } else if (properties != null) {
        virtualJPAEntity.create(properties);
      } else {
View Full Code Here

      final JPAEntity virtualJPAEntity = new JPAEntity(oDataEntityType, oDataEntitySet, oDataJPAContext);
      virtualJPAEntity.setJPAEntity(jpaEntity);

      if (content != null) {
        final ODataEntityParser oDataEntityParser = new ODataEntityParser(oDataJPAContext);
        final ODataEntry oDataEntry = oDataEntityParser.parseEntry(oDataEntitySet, content, requestContentType, false);
        virtualJPAEntity.update(oDataEntry);
      } else if (properties != null) {
        virtualJPAEntity.update(properties);
      } else {
        return null;
View Full Code Here

              ReadFeedResult result = new ReadFeedResult(inlineReadProperties, navigationProperty, feed);
              callback.handleReadFeed(result);
            }
          } else {
            JsonEntryConsumer inlineConsumer = new JsonEntryConsumer(reader, inlineEia, inlineReadProperties);
            ODataEntry entry = inlineConsumer.readInlineEntry(name);
            updateExpandSelectTree(navigationPropertyName, entry);
            if (callback == null) {
              properties.put(navigationPropertyName, entry);
              resultEntry.setContainsInlineEntry(true);
            } else {
View Full Code Here

  public void readEntry() throws Exception {
    final String contentType = ContentType.APPLICATION_ATOM_XML_ENTRY.toContentTypeString();
    final EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
    InputStream content = new ByteArrayInputStream(EMPLOYEE_1_XML.getBytes("UTF-8"));

    final ODataEntry result =
        new ProviderFacadeImpl().readEntry(contentType, entitySet, content, EntityProviderReadProperties.init()
            .mergeSemantic(true).build());
    assertNotNull(result);
    assertFalse(result.containsInlineEntry());
    assertNotNull(result.getExpandSelectTree());
    assertTrue(result.getExpandSelectTree().isAll());
    assertNotNull(result.getMetadata());
    assertNull(result.getMetadata().getEtag());
    assertNotNull(result.getMediaMetadata());
    assertEquals(HttpContentType.APPLICATION_OCTET_STREAM, result.getMediaMetadata().getContentType());
    assertNotNull(result.getProperties());
    assertEquals(52, result.getProperties().get("Age"));
  }
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.ep.entry.ODataEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.