Package org.apache.olingo.odata2.annotation.processor.core.model

Examples of org.apache.olingo.odata2.annotation.processor.core.model.Room


    building.setName("Common Building");

    final int roomsCount = 11;
    List<Room> rooms = new ArrayList<Room>();
    for (int i = 0; i < roomsCount; i++) {
      Room room = new Room(i, "Room " + i);
      room.setBuilding(building);
      datasource.createData(roomsEntitySet, room);
      rooms.add(room);
    }

    // execute
    Object relatedData = datasource.readData(roomsEntitySet);

    // validate
    @SuppressWarnings("unchecked")
    Collection<Room> relatedRooms = (Collection<Room>) relatedData;
    Assert.assertEquals(roomsCount, relatedRooms.size());
    for (Room room : relatedRooms) {
      Assert.assertNotNull(room.getId());
      Assert.assertTrue(room.getName().matches("Room \\d*"));
      Assert.assertEquals("Common Building", room.getBuilding().getName());
    }
  }
View Full Code Here


    building.setName("Common Building");

    final int roomsCount = 10;
    List<Room> rooms = new ArrayList<Room>();
    for (int i = 0; i < roomsCount; i++) {
      Room room = new Room(i, "Room " + i);
      room.setBuilding(building);
      datasource.createData(roomsEntitySet, room);
      rooms.add(room);
    }

    building.getRooms().addAll(rooms);
    datasource.createData(buildingsEntitySet, building);

    Map<String, Object> keys = new HashMap<String, Object>();
    keys.put("Id", "1");

    Building read = (Building) datasource.readData(buildingsEntitySet, keys);
    Assert.assertEquals("Common Building", read.getName());
    Assert.assertEquals("1", read.getId());

    // execute
    Object relatedData = datasource.readRelatedData(
        buildingsEntitySet, building, roomsEntitySet, Collections.EMPTY_MAP);

    // validate
    Assert.assertTrue("Result is no collection.", relatedData instanceof Collection);
    Collection<Room> relatedRooms = (Collection<Room>) relatedData;
    Assert.assertEquals(roomsCount, relatedRooms.size());
    for (Room room : relatedRooms) {
      Assert.assertNotNull(room.getId());
      Assert.assertTrue(room.getName().matches("Room \\d*"));
      Assert.assertEquals("Common Building", room.getBuilding().getName());
    }
  }
View Full Code Here

    EdmEntitySet roomsEntitySet = createMockedEdmEntitySet("Rooms");

    Building building = new Building();
    building.setName("Common Building");

    Room room = new Room(12, "Room 12");
    room.setBuilding(building);
    datasource.createData(roomsEntitySet, room);
    datasource.createData(buildingsEntitySet, building);

    Map<String, Object> keys = new HashMap<String, Object>();
    keys.put("Id", Integer.valueOf(12));
    Room read = (Room) datasource.readData(roomsEntitySet, keys);
    Assert.assertEquals("Room 12", read.getName());
    Assert.assertEquals("12", read.getId());

    // execute
    Object relatedData = datasource.readRelatedData(
        roomsEntitySet, room, buildingsEntitySet, Collections.EMPTY_MAP);
View Full Code Here

    Building building = new Building();
    building.setName("Common Building");
    datasource.createData(buildingsEntitySet, building);

    Room room = new Room(12, "Room 12");
    room.setBuilding(null);
    datasource.createData(roomsEntitySet, room);
    //
    Map<String, Object> keys = new HashMap<String, Object>();
    keys.put("Id", Integer.valueOf(12));
    Room read = (Room) datasource.readData(roomsEntitySet, keys);
    Assert.assertEquals("Room 12", read.getName());
    Assert.assertEquals("12", read.getId());

    // execute
    Object relatedData = datasource.readRelatedData(
        roomsEntitySet, room, buildingsEntitySet, Collections.EMPTY_MAP);
View Full Code Here

    building.setName("Common Building");

    final int roomsCount = 10;
    List<Room> rooms = new ArrayList<Room>();
    for (int i = 0; i < roomsCount; i++) {
      Room room = new Room(i, "Room " + i);
      room.setBuilding(building);
      datasource.createData(roomsEntitySet, room);
      rooms.add(room);
    }

    building.getRooms().addAll(rooms);
    datasource.createData(buildingsEntitySet, building);

    Map<String, Object> keys = new HashMap<String, Object>();
    keys.put("Id", "1");

    Building read = (Building) datasource.readData(buildingsEntitySet, keys);
    Assert.assertEquals("Common Building", read.getName());
    Assert.assertEquals("1", read.getId());

    // execute
    Map<String, Object> targetKeys = new HashMap<String, Object>();
    targetKeys.put("Id", 3);
    Object relatedData = datasource.readRelatedData(
        buildingsEntitySet, building, roomsEntitySet, targetKeys);

    // validate
    Assert.assertTrue("Result is no Room.", relatedData instanceof Room);
    Room relatedRoom = (Room) relatedData;
    Assert.assertEquals("3", relatedRoom.getId());
    Assert.assertEquals("Room 3", relatedRoom.getName());
    Assert.assertEquals("Common Building", relatedRoom.getBuilding().getName());
  }
View Full Code Here

    Building building = new Building();
    building.setName("Common Building");
    Building created = buildingStore.create(building);

    Room room = new Room(42, "Room with Number");
    room.setSeats(123);
    ;
    room.setVersion(4711);
    roomStore.create(room);

    Map<String, Object> targetEntityKeyValues = new HashMap<String, Object>();
    targetEntityKeyValues.put("Id", 42);

    // execute
    datasource.writeRelation(buildingsEntitySet, building, roomsEntitySet, targetEntityKeyValues);

    // validate
    Building readBuilding = buildingStore.read(created);
    Room readRoom = roomStore.read(new Room(42, ""));

    List<Room> readRooms = readBuilding.getRooms();
    Assert.assertEquals(1, readRooms.size());
    Assert.assertEquals(readRoom, readRooms.get(0));

    Assert.assertEquals("42", readRoom.getId());
    Assert.assertEquals(123, readRoom.getSeats());
    Assert.assertEquals(4711, readRoom.getVersion());
    Assert.assertEquals(readBuilding, readRoom.getBuilding());
  }
View Full Code Here

        final String contentHeader = ContentType.create(BATCH_CONTENT_TYPE, BOUNDARY_PARAMETER, boundary).toString();
        return ODataResponse.entity(batchRequest).contentHeader(contentHeader).build();
    }

    private void addChangeSetParts(ArrayList<BatchPart> parts, ArrayList<BatchChangeSetPart> changeSetParts) {
        final BatchChangeSet changeSet = BatchChangeSet.newBuilder().build();
        for (BatchChangeSetPart changeSetPart : changeSetParts) {
            changeSet.add(changeSetPart);
        }
        parts.add(changeSet);
    }
View Full Code Here

                parts.add(createBatchQueryPart(uriInfo, (Olingo2BatchQueryRequest) batchPart));

            } else {

                // add to change set parts
                final BatchChangeSetPart changeSetPart = createBatchChangeSetPart(
                    edm, contentIdMap, (Olingo2BatchChangeRequest) batchPart);
                changeSetParts.add(changeSetPart);
            }
        }
View Full Code Here

                @Override
                public void onCompleted(HttpResponse result)
                    throws IOException, EntityProviderException, BatchException, ODataApplicationException {

                    // if a entity is created (via POST request) the response body contains the new created entity
                    HttpStatusCodes statusCode = HttpStatusCodes.fromStatusCode(result.getStatusLine().getStatusCode());

                    // look for no content, or no response body!!!
                    final boolean noEntity = result.getEntity() == null || result.getEntity().getContentLength() == 0;
                    if (statusCode == HttpStatusCodes.NO_CONTENT || noEntity) {
                        responseHandler.onResponse(
View Full Code Here

        LOG.info("Updated Entry successfully:  {}", prettyPrint(updatedEntry));

        statusHandler.reset();
        olingoApp.delete(TEST_CREATE_MANUFACTURER,  statusHandler);

        HttpStatusCodes statusCode = statusHandler.await();
        LOG.info("Deletion of Entry was successful:  {}: {}", statusCode.getStatusCode(), statusCode.getInfo());

        try {
            LOG.info("Verify Delete Entry");

            entryHandler.reset();
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.annotation.processor.core.model.Room

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.