Ejemplo n.º 1
0
  @Test
  public void copy_construct_with_overwrite() throws Exception {

    final Context old =
        ContextBuilder.create()
            .repositoryId("repository")
            .branch("branch")
            .attribute("key1", "value1")
            .build();

    final Branch newWS = Branch.from("new");
    final Context newContext = ContextBuilder.from(old).branch(newWS).build();

    assertEquals(newWS, newContext.getBranch());
    assertEquals("repository", newContext.getRepositoryId().toString());
  }
Ejemplo n.º 2
0
  @Test
  public void testBuildFrom() {
    final Context old =
        ContextBuilder.create()
            .repositoryId("repository")
            .branch("branch")
            .attribute("key1", "value1")
            .build();

    final ContextBuilder builder = ContextBuilder.from(old);

    final SampleValue sampleValue = new SampleValue();
    builder.attribute(sampleValue);

    final Context context = builder.build();
    assertNotNull(context);
    assertEquals("repository", context.getRepositoryId().toString());
    assertEquals("branch", context.getBranch().toString());
    assertEquals(AuthenticationInfo.unAuthenticated(), context.getAuthInfo());
    assertEquals("value1", context.getAttribute("key1"));
    assertSame(sampleValue, context.getAttribute(SampleValue.class));
  }