@Test public void builder_forSimpleType() { // Given(SetUp) // When(Exercise) final TypedDefaultMutableTreeNodeBuilder<String> builder = TypedDefaultMutableTreeNodeBuilder.newBuilder(TypeToken.of(String.class)); final String data1 = "1"; final String data2 = "2"; final TypedDefaultMutableTreeNode<String> node = builder.build(data1); // Then(Verify) TypedDefaultMutableTreeNodeTest.compareAndSetUserObject(node, data1, data2); Assert.assertEquals(node.getUserObject(), data2); }
@Test public void builder_forGenericType() { // Given(SetUp) // When(Exercise) final TypedDefaultMutableTreeNodeBuilder<List<String>> builder = TypedDefaultMutableTreeNodeBuilder.newBuilder(new TypeToken<List<String>>() {}); final List<String> data1 = Lists.newArrayList("1", "2"); final List<String> data2 = Lists.newArrayList("3", "4"); final TypedDefaultMutableTreeNode<List<String>> node = builder.build(data1); // Then(Verify) TypedDefaultMutableTreeNodeTest.compareAndSetUserObject(node, data1, data2); Assert.assertEquals(node.getUserObject(), data2); }
@Test public void builder_forWildcardType() { // Given(SetUp) // When(Exercise) final TypedDefaultMutableTreeNodeBuilder<List<? extends Number>> builder = TypedDefaultMutableTreeNodeBuilder.newBuilder(new TypeToken<List<? extends Number>>() {}); final List<Integer> data1 = Lists.newArrayList(Integer.valueOf(1)); final List<Double> data2 = Lists.newArrayList(Double.valueOf(1.0)); final TypedDefaultMutableTreeNode<List<? extends Number>> node = builder.build(data1); // Then(Verify) TypedDefaultMutableTreeNodeTest.compareAndSetUserObject(node, data1, data2); Assert.assertEquals(node.getUserObject(), data2); }