Ejemplo n.º 1
0
  @Test
  public void test_getUniqueBucketSignature() {

    final String path1 = "/test+extra/";
    final String path2 = "/test+extra/4354____42";
    final String path3 = "test+extra/4354____42/some/more/COMPONENTS_VERY_VERY_LONG";

    assertEquals(
        "test_extra__c1651d4c69ed", BucketUtils.getUniqueSignature(path1, Optional.empty()));
    assertEquals(
        "test_extra_test_12345__c1651d4c69ed",
        BucketUtils.getUniqueSignature(path1, Optional.of("test+;12345")));
    assertEquals(
        "test_extra_4354_42__bb8a6a382d7b",
        BucketUtils.getUniqueSignature(path2, Optional.empty()));
    assertEquals(
        "test_extra_4354_42_t__bb8a6a382d7b",
        BucketUtils.getUniqueSignature(path2, Optional.of("t")));
    assertEquals(
        "test_extra_more_components_very__7768508661fc",
        BucketUtils.getUniqueSignature(path3, Optional.empty()));
    assertEquals(
        "test_extra_more_components_very_xx__7768508661fc",
        BucketUtils.getUniqueSignature(path3, Optional.of("XX__________")));
  }
Ejemplo n.º 2
0
  @Test
  public void test_ConvertDataBucketBeanToTest() {
    String original_full_name = "/my_bean/sample_path";
    String original_id = "id12345";
    String user_id = "user12345";
    DataBucketBean original_bean =
        BeanTemplateUtils.build(DataBucketBean.class)
            .with(DataBucketBean::_id, "id12345")
            .with(DataBucketBean::full_name, original_full_name)
            .done()
            .get();

    DataBucketBean test_bean = BucketUtils.convertDataBucketBeanToTest(original_bean, user_id);

    assertTrue(test_bean._id().equals(original_id));
    assertTrue(
        "Name is wrong: " + test_bean.full_name(),
        test_bean.full_name().equals("/aleph2_testing/" + user_id + original_full_name));

    assertTrue(BucketUtils.isTestBucket(test_bean));
    assertFalse(BucketUtils.isTestBucket(original_bean));
  }