@Test
  public void testEndpointConsumptionRelations() throws Exception {
    // Create endpoint consumption
    SoaNodeId endpointConsumptionId = new SoaNodeId(EndpointConsumption.DOCTYPE, "MyConsumption");
    DocumentModel endpointConsumptionModel =
        documentService.create(documentManager, endpointConsumptionId);
    EndpointConsumption endpointConsumption =
        endpointConsumptionModel.getAdapter(EndpointConsumption.class);
    Assert.assertNotNull("EndpointConsumption adapter must be available", endpointConsumption);
    documentManager.save();

    // Manipulate and test it
    Assert.assertNull(
        "EndpointConsumption must not initially consume endpoints",
        endpointConsumption.getConsumedEndpoint());
    SoaNodeId consumedEndpoint = new EndpointId("myenv", "myurl");
    endpointConsumption.setConsumedEndpoint(consumedEndpoint);
    Assert.assertEquals(
        "EndpointConsumption must be set as expected",
        consumedEndpoint,
        endpointConsumption.getConsumedEndpoint());
    DocumentModel foundEndpointModel =
        documentService.findSoaNode(documentManager, consumedEndpoint);
    Assert.assertNotNull("Consumed endpoint must be created", foundEndpointModel);
    endpointConsumption.setConsumedEndpoint(null);
    Assert.assertNull(
        "EndpointConsumption must be removed", endpointConsumption.getConsumedEndpoint());
  }
  @Test
  public void testDocumentAdapters() throws ClientException {

    // Create a deliverable
    DocumentModel deliverableModel =
        documentService.create(
            documentManager,
            new SoaNodeId(Deliverable.DOCTYPE, "MyDeliverable"),
            DocumentModelHelper.getWorkspacesPath(documentManager, defaultSubprojectId));

    // Use its adapter
    Deliverable deliverable = deliverableModel.getAdapter(Deliverable.class);
    Assert.assertNotNull("Document model must be adapted as a deliverable", deliverable);
  }
  @Test
  public void testServiceImplComplexProps() throws Exception {

    // Create ServiceImpl
    SoaNodeId serviceImplId = new SoaNodeId(ServiceImplementation.DOCTYPE, "MyServiceImpl");
    DocumentModel serviceImplModel = documentService.create(documentManager, serviceImplId);

    String opName = "Yo";
    String params = "Param1:java.lang.int, Param2:my.Class";
    String returnParams = "YoResponse:java.lang.String";
    String opDoc = "This does something";
    String inContentType = "text/xml";
    String outContentType =
        "application/json"; // http://stackoverflow.com/questions/477816/what-is-the-correct-json-content-type

    // Use adapter to manipulate operations
    ServiceImplementation serviceImpl = serviceImplModel.getAdapter(ServiceImplementation.class);
    List<OperationInformation> operations = serviceImpl.getOperations();
    operations.add(
        new OperationInformation(
            opName, params, returnParams, opDoc, inContentType, outContentType));
    serviceImpl.setOperations(operations);
    List<String> tests = new ArrayList<String>();
    tests.add("org.easysoa.TestClass1");
    tests.add("org.easysoa.TestClass2");
    serviceImpl.setTests(tests);

    // Save
    documentManager.saveDocument(serviceImplModel);
    documentManager.save();

    // Fetch document again, check operations update
    serviceImplModel = documentService.findSoaNode(documentManager, serviceImplId);
    serviceImpl = serviceImplModel.getAdapter(ServiceImplementation.class);
    operations = serviceImpl.getOperations();
    Assert.assertEquals(1, operations.size());
    Assert.assertEquals(opName, operations.get(0).getName());
    Assert.assertEquals(params, operations.get(0).getParameters());
    Assert.assertEquals(returnParams, operations.get(0).getReturnParameters());
    Assert.assertEquals(opDoc, operations.get(0).getDocumentation());
    Assert.assertEquals(inContentType, operations.get(0).getInContentType());
    Assert.assertEquals(outContentType, operations.get(0).getOutContentType());
    Assert.assertEquals(opDoc, operations.get(0).getDocumentation());
    Assert.assertEquals(2, serviceImpl.getTests().size());
  }