use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class MarkupContainerTest method iteratorShouldAllowReplacingComponentAfterIterationStarted0.
@Test
public void iteratorShouldAllowReplacingComponentAfterIterationStarted0() {
WebMarkupContainer wmc = new WebMarkupContainer("id");
Label label1;
Label label2;
Label label3;
wmc.add(label1 = new Label("label1", "Label1"));
wmc.add(label2 = new Label("label2", "Label2"));
Iterator<Component> iterator = wmc.iterator();
wmc.replace(label3 = new Label("label1", "Label3"));
Assert.assertThat(iterator.next(), is(equalToObject(label3)));
Assert.assertThat(iterator.next(), is(equalToObject(label2)));
Assert.assertThat(iterator.hasNext(), is(false));
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class MarkupContainerTest method singleChildShouldAllowReplacingChildAfterIterationHasStarted.
@Test
public void singleChildShouldAllowReplacingChildAfterIterationHasStarted() {
WebMarkupContainer wmc = new WebMarkupContainer("id");
Component label1 = new Label("label1", "Label1");
Component label2 = new Label("label1", "Label2");
wmc.add(label1);
Iterator<Component> iterator = wmc.iterator();
wmc.replace(label2);
Assert.assertThat(iterator.hasNext(), is(true));
Assert.assertThat(iterator.next(), is(sameInstance(label2)));
Assert.assertThat(iterator.hasNext(), is(false));
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class MarkupContainerTest method noChildAddingChildAfterIteratorAcquiredShouldIterateAndReturnNewChild.
@Test
public void noChildAddingChildAfterIteratorAcquiredShouldIterateAndReturnNewChild() {
WebMarkupContainer wmc = new WebMarkupContainer("id");
Iterator<Component> iterator = wmc.iterator();
Label label1 = new Label("label1", "Label1");
wmc.add(label1);
assertThat(wmc.size(), is(1));
Assert.assertThat(iterator.hasNext(), is(true));
Assert.assertThat(iterator.next(), is(equalToObject(label1)));
Assert.assertThat(iterator.hasNext(), is(false));
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class MarkupContainerTest method iteratorShouldAllowReplacingComponentAfterIterationStarted24.
@Test
public void iteratorShouldAllowReplacingComponentAfterIterationStarted24() {
WebMarkupContainer wmc = new WebMarkupContainer("id");
Label label1;
Label label2;
Label label3;
wmc.add(label1 = new Label("label1", "Label1"));
wmc.add(label2 = new Label("label2", "Label2"));
addNChildren(wmc, NUMBER_OF_CHILDREN_FOR_A_MAP);
Iterator<Component> iterator = wmc.iterator();
Assert.assertThat(iterator.next(), is(equalToObject(label1)));
wmc.replace(label3 = new Label("label2", "Label3"));
Assert.assertThat(iterator.next(), is(equalToObject(label3)));
takeNChildren(iterator, NUMBER_OF_CHILDREN_FOR_A_MAP);
Assert.assertThat(iterator.hasNext(), is(false));
}
use of org.apache.wicket.markup.html.basic.Label in project wicket by apache.
the class MarkupContainerTest method iteratorShouldAllowAddingComponentAfterIterationStarted.
@Test
public void iteratorShouldAllowAddingComponentAfterIterationStarted() {
WebMarkupContainer wmc = new WebMarkupContainer("id");
Label label1;
Label label2;
Label label3;
wmc.add(label1 = new Label("label1", "Label1"));
wmc.add(label2 = new Label("label2", "Label2"));
Iterator<Component> iterator = wmc.iterator();
Assert.assertThat(iterator.next(), is(equalToObject(label1)));
Assert.assertThat(iterator.next(), is(equalToObject(label2)));
wmc.add(label3 = new Label("label3", "Label3"));
Assert.assertThat(iterator.next(), is(equalToObject(label3)));
Assert.assertThat(iterator.hasNext(), is(false));
}
Aggregations