@Before
  public void setUp() throws Exception {
    givenTimeIs(firstDocumentModificationOClock);

    defineSchemasManager().using(schemas.withAContentMetadata());

    MetadataSchemasManager metadataSchemasManager =
        getModelLayerFactory().getMetadataSchemasManager();
    TaxonomiesManager taxonomiesManager = getModelLayerFactory().getTaxonomiesManager();
    Taxonomy taxonomy =
        Taxonomy.createPublic("taxo", "taxo", zeCollection, Arrays.asList("zeSchemaType"));
    taxonomiesManager.addTaxonomy(taxonomy, metadataSchemasManager);
    taxonomiesManager.setPrincipalTaxonomy(taxonomy, metadataSchemasManager);

    getModelLayerFactory()
        .newUserServices()
        .addUpdateUserCredential(
            new UserCredential(
                "bob",
                "bob",
                "gratton",
                "*****@*****.**",
                new ArrayList<String>(),
                Arrays.asList(zeCollection),
                UserCredentialStatus.ACTIVE,
                null));

    getModelLayerFactory()
        .newUserServices()
        .addUpdateUserCredential(
            new UserCredential(
                "alice",
                "alice",
                "wonderland",
                "*****@*****.**",
                new ArrayList<String>(),
                Arrays.asList(zeCollection),
                UserCredentialStatus.ACTIVE,
                null));

    alice = getModelLayerFactory().newUserServices().getUserInCollection("alice", zeCollection);
    bob = getModelLayerFactory().newUserServices().getUserInCollection("bob", zeCollection);
    getModelLayerFactory().newAuthenticationService().changePassword("alice", "1qaz2wsx");
    getModelLayerFactory().newAuthenticationService().changePassword("bob", "1qaz2wsx");

    aliceId = alice.getId();
    bobId = bob.getId();

    recordServices = getModelLayerFactory().newRecordServices();
    contentManager = getModelLayerFactory().getContentManager();

    alice.setCollectionDeleteAccess(true);
    bob.setCollectionDeleteAccess(true);
    alice.setCollectionWriteAccess(true);
    bob.setCollectionWriteAccess(true);
    recordServices.update(alice.getWrappedRecord());
    recordServices.update(bob.getWrappedRecord());
  }
  private void _1_documentCreation(Folder folder) throws IOException {
    Map<String, Object> properties = new HashMap<>();
    properties.put("metadata", "contentMetadata");
    properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
    Document cmisContent =
        folder.createDocument(properties, pdf1ContentStream(), VersioningState.MAJOR);
    Content content = recordServices.getDocumentById(zeRecord).get(zeSchema.contentMetadata());
    assertThat(cmisContent.getId())
        .isEqualTo("content_" + zeRecord + "_contentMetadata_" + content.getId() + "_1.0");
    zeRecordContentId = content.getId();

    cmisContent = getSingleContentOf(zeRecord);
    assertThatContentStreamIsSameAs(cmisContent, pdf1ContentStream(), pdf1Hash);
    assertThatVersionCreationInfoAre(cmisContent, aliceId, documentCreationOClock);
    assertThat(cmisContent.getId())
        .isEqualTo("content_" + zeRecord + "_contentMetadata_" + content.getId() + "_1.0");
    assertThat(cmisContent.getProperty(PropertyIds.PARENT_ID).getValue()).isEqualTo(zeRecord);
    assertThat(cmisContent.getVersionLabel()).isEqualTo("1.0");
    assertThat(cmisContent.getVersionSeriesCheckedOutBy()).isNull();
    //		assertThat(cmisContent.getVersionSeriesCheckedOutId()).isNull();
    assertThat(cmisContent.getVersionSeriesId())
        .isEqualTo("content_" + zeRecord + "_contentMetadata_" + content.getId());
    assertThat(cmisContent.isLatestMajorVersion()).isTrue();
    assertThat(cmisContent.isLatestVersion()).isTrue();
    assertThat(cmisContent.isMajorVersion()).isTrue();
    //		assertThat(cmisContent.isPrivateWorkingCopy()).isFalse();
    assertThat(cmisContent.isVersionSeriesCheckedOut()).isFalse();
    assertThat(cmisContent.getPropertyValue("metadata")).isEqualTo("contentMetadata");
  }
 private Document _2_firstDocumentModification() throws IOException {
   Document cmisContent = getContentsOf(zeRecord).get(0);
   cmisContent.setContentStream(docx1ContentStream(), true);
   recordServices.refresh(recordServices.getDocumentById(zeRecord));
   cmisContent = getContentsOf(zeRecord).get(0);
   assertThatContentStreamIsSameAs(cmisContent, docx1ContentStream(), docx1Hash);
   assertThatVersionCreationInfoAre(cmisContent, bobId, firstDocumentModificationOClock);
   assertThat(cmisContent.getId())
       .isEqualTo("content_" + zeRecord + "_contentMetadata_" + zeRecordContentId + "_1.1");
   assertThat(cmisContent.getProperty(PropertyIds.PARENT_ID).getValue()).isEqualTo(zeRecord);
   assertThat(cmisContent.getVersionLabel()).isEqualTo("1.1");
   assertThat(cmisContent.getVersionSeriesCheckedOutBy()).isNull();
   assertThat(cmisContent.getVersionSeriesCheckedOutId()).isNull();
   assertThat(cmisContent.getVersionSeriesId())
       .isEqualTo("content_" + zeRecord + "_contentMetadata_" + zeRecordContentId);
   assertThat(cmisContent.isLatestMajorVersion()).isFalse();
   assertThat(cmisContent.isLatestVersion()).isTrue();
   assertThat(cmisContent.isMajorVersion()).isFalse();
   //		assertThat(cmisContent.isPrivateWorkingCopy()).isFalse();
   assertThat(cmisContent.isVersionSeriesCheckedOut()).isFalse();
   assertThat(cmisContent.getPropertyValue("metadata")).isEqualTo("contentMetadata");
   return cmisContent;
 }
    private BaseClassificationRecords(RecordServices recordServices)
        throws RecordServicesException {
      this.recordServices = recordServices;

      Transaction transaction = new Transaction();

      records.add(category_A = createCategory(transaction, "category_A", null));
      records.add(category_A_1 = createCategory(transaction, "category_A_1", category_A));
      records.add(category_A_2 = createCategory(transaction, "category_A_2", category_A));
      records.add(category_B = createCategory(transaction, "category_B", null));
      records.add(category_B_1 = createCategory(transaction, "category_B_1", category_B));
      records.add(category_B_11 = createCategory(transaction, "category_B_11", category_B_1));
      records.add(category_B_12 = createCategory(transaction, "category_B_12", category_B_1));
      records.add(category_C = createCategory(transaction, "category_C", null));

      recordServices.execute(transaction);
    }
    private BaseClassificationComplexRecords(RecordServices recordServices)
        throws RecordServicesException {
      this.recordServices = recordServices;

      Transaction transaction = new Transaction();

      records.add(category_A = createCategory(transaction, "category_A", null));
      records.add(
          subCategory_SA1 = createSubCategory(transaction, "subCategory_SA1", category_A, null));
      records.add(
          subCategory_SA2 = createSubCategory(transaction, "subCategory_SA2", category_A, null));
      records.add(
          subCategory_SA2_1 =
              createSubCategory(transaction, "subCategory_SA2_1", null, subCategory_SA2));
      records.add(category_A_1 = createCategory(transaction, "category_A_1", category_A));
      records.add(category_A_2 = createCategory(transaction, "category_A_2", category_A));
      records.add(category_B = createCategory(transaction, "category_B", null));
      records.add(category_B_1 = createCategory(transaction, "category_B_1", category_B));
      records.add(category_C = createCategory(transaction, "category_C", null));

      recordServices.execute(transaction);
    }
 private String givenRecord() throws RecordServicesException {
   Record record = new TestRecord(zeSchema, "zeRecord");
   recordServices.add(record);
   return record.getId();
 }
 void open(HttpServletRequest request, HttpServletResponse response, int serviceCall) {
   RecordServices recordServices =
       getConstellioFactories().getModelLayerFactory().newRecordServices();
   String idWithTooMuchZeros = "0000000000" + serviceCall % 1000000;
   recordServices.getDocumentById(idWithTooMuchZeros.substring(idWithTooMuchZeros.length() - 11));
 }