use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Container in project mdsal by opendaylight.
the class Mdsal298Test method testKeyedDataTreeModification.
@Test
public void testKeyedDataTreeModification() throws InterruptedException, ExecutionException {
final DataTreeChangeListener<Container> listener = assertWrittenContainer(Container.QNAME, Container.class, new ContainerBuilder().build());
final DOMDataTreeWriteTransaction domTx = getDomBroker().newWriteOnlyTransaction();
domTx.put(CONFIGURATION, YangInstanceIdentifier.create(CONTAINER_NID).node(Keyed.QNAME), Builders.orderedMapBuilder().withNodeIdentifier(new NodeIdentifier(Keyed.QNAME)).addChild(Builders.mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(Keyed.QNAME, FOO_QNAME, "foo")).addChild(ImmutableNodes.leafNode(FOO_QNAME, "foo")).build()).addChild(Builders.mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(Keyed.QNAME, FOO_QNAME, "bar")).addChild(ImmutableNodes.leafNode(FOO_QNAME, "bar")).build()).build());
domTx.commit().get();
final ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);
verify(listener).onDataTreeChanged(captor.capture());
Collection<DataTreeModification<Container>> capture = captor.getValue();
assertEquals(1, capture.size());
final DataTreeModification<Container> change = capture.iterator().next();
assertEquals(CONTAINER_TID, change.getRootPath());
final DataObjectModification<Container> changedContainer = change.getRootNode();
assertEquals(Item.of(Container.class), changedContainer.getIdentifier());
assertEquals(ModificationType.SUBTREE_MODIFIED, changedContainer.getModificationType());
final Container containerAfter = changedContainer.getDataAfter();
assertEquals(new ContainerBuilder().setKeyed(List.of(new KeyedBuilder().setFoo("foo").withKey(new KeyedKey("foo")).build(), new KeyedBuilder().setFoo("bar").withKey(new KeyedKey("bar")).build())).build(), containerAfter);
final Collection<? extends DataObjectModification<?>> changedChildren = changedContainer.getModifiedChildren();
assertEquals(2, changedChildren.size());
final Iterator<? extends DataObjectModification<?>> it = changedChildren.iterator();
final DataObjectModification<?> changedChild1 = it.next();
assertEquals(ModificationType.WRITE, changedChild1.getModificationType());
assertEquals(List.of(), changedChild1.getModifiedChildren());
final Keyed child1After = (Keyed) changedChild1.getDataAfter();
assertEquals("foo", child1After.getFoo());
final DataObjectModification<?> changedChild2 = it.next();
assertEquals(ModificationType.WRITE, changedChild2.getModificationType());
assertEquals(List.of(), changedChild2.getModifiedChildren());
final Keyed child2After = (Keyed) changedChild2.getDataAfter();
assertEquals("bar", child2After.getFoo());
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Container in project mdsal by opendaylight.
the class TestListSquashing method testUserOrderedList.
@Test
public void testUserOrderedList() {
final Keyed keyed = new KeyedBuilder().withKey(new KeyedKey("a")).build();
final Unkeyed unkeyed = new UnkeyedBuilder().build();
final Container cont = new ContainerBuilder().setKeyed(List.of(keyed)).setUnkeyed(List.of(unkeyed)).build();
// Non-empty Lists should be retained
assertEquals(List.of(keyed), cont.getKeyed());
assertEquals(List.of(unkeyed), cont.getUnkeyed());
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Container in project WildChests by BG-Software-LLC.
the class NMSInventory_v1_16_R3 method openPage.
@Override
public void openPage(Player player, com.bgsoftware.wildchests.objects.inventory.CraftWildInventory inventory) {
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
String title = inventory.getTitle();
Container container = createContainer(entityPlayer.nextContainerCounter(), entityPlayer.inventory, inventory);
container.setTitle(new ChatComponentText(title));
entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, container.getType(), container.getTitle()));
entityPlayer.activeContainer = container;
entityPlayer.activeContainer.addSlotListener(entityPlayer);
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Container in project PublicCrafters by BananaPuncher714.
the class CustomInventoryCrafting method setItem.
@Override
public void setItem(int index, ItemStack item) {
// Instead of updating one container, update all the containers
// That are looking at the table, basically the viewers
items.set(index, item == null ? ItemStack.a : item);
for (Container container : containers) {
container.a(this);
}
// Update the armorstand grid
display.update();
}
use of com.marcnuri.yakc.model.io.k8s.api.core.v1.Container in project PublicCrafters by BananaPuncher714.
the class CustomInventoryCrafting method splitStack.
@Override
public ItemStack splitStack(int i, int j) {
ItemStack itemstack = ContainerUtil.a(items, i, j);
if (!itemstack.isEmpty()) {
for (Container container : containers) {
container.a(this);
}
}
// Update the armorstand grid
display.update();
return itemstack;
}
Aggregations