use of net.minecraft.server.v1_10_R1.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[index] = item;
for (Container container : containers) {
container.a(this);
}
// Update the armorstand grid
display.update();
}
use of net.minecraft.server.v1_10_R1.Container in project tests by datanucleus.
the class BasicTest method testInh2.
public void testInh2() {
try {
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
Base base1 = new Base(1, "b1");
Base base2 = new Base(2, "b2");
Base base3 = new Base(3, "b3");
SubBase group1 = new SubBase(4, "b4", "SB1");
SubBase group2 = new SubBase(5, "b5", "SB2");
Container c = new Container(new Base[] { base1, base2, base3, group1, group2 });
pm.makePersistent(c);
tx.commit();
tx.begin();
Collection col = (Collection) pm.newQuery(SubBase.class).execute();
assertTrue(col.size() == 2);
assertTrue(col.contains(group1));
assertTrue(col.contains(group2));
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
} finally {
clean(Container.class);
clean(SubBase.class);
clean(Base.class);
}
}
use of net.minecraft.server.v1_10_R1.Container in project flytekit-java by flyteorg.
the class ProjectClosureTest method testCreateTaskTemplateForRunnableTaskWithResources.
@Test
public void testCreateTaskTemplateForRunnableTaskWithResources() {
// given
Map<Resources.ResourceName, String> resourceValues = new HashMap<>();
resourceValues.put(Resources.ResourceName.MEMORY, "0.5Gi");
Resources expectedResources = Resources.builder().limits(resourceValues).requests(resourceValues).build();
RunnableTask task = createRunnableTask(expectedResources);
String image = "my-image";
// when
TaskTemplate result = ProjectClosure.createTaskTemplateForRunnableTask(task, image);
// then
Container container = result.container();
assertNotNull(container);
assertThat(container.image(), equalTo(image));
assertThat(container.resources(), equalTo(expectedResources));
assertThat(result.interface_(), equalTo(TypedInterface.builder().inputs(SdkTypes.nulls().getVariableMap()).outputs(SdkTypes.nulls().getVariableMap()).build()));
assertThat(result.custom(), equalTo(Struct.of(emptyMap())));
assertThat(result.retries(), equalTo(RetryStrategy.builder().retries(0).build()));
assertThat(result.type(), equalTo("java-task"));
}
use of net.minecraft.server.v1_10_R1.Container in project flytekit-java by flyteorg.
the class ProtoUtilTest method shouldSerDeTaskTemplate.
@Test
void shouldSerDeTaskTemplate() {
Container container = Container.builder().command(ImmutableList.of("echo")).args(ImmutableList.of("hello world")).env(ImmutableList.of(KeyValuePair.of("key", "value"))).image("alpine:3.7").build();
Variable stringVar = ApiUtils.createVar(SimpleType.STRING);
Variable integerVar = ApiUtils.createVar(SimpleType.INTEGER);
TypedInterface interface_ = TypedInterface.builder().inputs(ImmutableMap.of("x", stringVar)).outputs(ImmutableMap.of("y", integerVar)).build();
RetryStrategy retries = RetryStrategy.builder().retries(4).build();
TaskTemplate template = TaskTemplate.builder().container(container).type("custom-task").interface_(interface_).retries(retries).custom(Struct.of(ImmutableMap.of("custom-prop", Struct.Value.ofStringValue("custom-value")))).build();
Tasks.TaskTemplate templateProto = Tasks.TaskTemplate.newBuilder().setContainer(Tasks.Container.newBuilder().setImage("alpine:3.7").addCommand("echo").addArgs("hello world").addEnv(Literals.KeyValuePair.newBuilder().setKey("key").setValue("value").build()).build()).setMetadata(Tasks.TaskMetadata.newBuilder().setRuntime(Tasks.RuntimeMetadata.newBuilder().setType(Tasks.RuntimeMetadata.RuntimeType.FLYTE_SDK).setFlavor(ProtoUtil.RUNTIME_FLAVOR).setVersion(ProtoUtil.RUNTIME_VERSION).build()).setRetries(Literals.RetryStrategy.newBuilder().setRetries(4).build()).build()).setInterface(Interface.TypedInterface.newBuilder().setInputs(Interface.VariableMap.newBuilder().putVariables("x", Interface.Variable.newBuilder().setType(Types.LiteralType.newBuilder().setSimple(Types.SimpleType.STRING).build()).build()).build()).setOutputs(Interface.VariableMap.newBuilder().putVariables("y", Interface.Variable.newBuilder().setType(Types.LiteralType.newBuilder().setSimple(Types.SimpleType.INTEGER).build()).build()).build()).build()).setType("custom-task").setCustom(com.google.protobuf.Struct.newBuilder().putFields("custom-prop", Value.newBuilder().setStringValue("custom-value").build()).build()).build();
Tasks.TaskTemplate serializedTemplate = ProtoUtil.serialize(template);
TaskTemplate deserializedTemplate = ProtoUtil.deserialize(templateProto);
assertThat(serializedTemplate, equalTo(templateProto));
assertThat(deserializedTemplate, equalTo(template));
}
use of net.minecraft.server.v1_10_R1.Container in project flytekit-java by flyteorg.
the class ProtoUtilTest method shouldRejectResourcesWithInvalidQuantities.
@ParameterizedTest
@ValueSource(strings = { "", "1.1.", "+-1", "2+2", "Ki", "1Qi", "-1", "-5G" })
void shouldRejectResourcesWithInvalidQuantities(String quantity) {
Container container = createContainer(Resources.builder().requests(ImmutableMap.of(Resources.ResourceName.CPU, quantity)).build());
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> ProtoUtil.serialize(container));
assertEquals("Resource requests [CPU] has invalid quantity: " + quantity, exception.getMessage());
}
Aggregations