### Question:
PutContract extends Contract { @Override public JsonObject invoke(Ledger ledger, JsonObject argument, Optional<JsonObject> property) { if (!(argument.containsKey("asset_id") && argument.containsKey("data"))) { throw new ContractContextException("a required attribute is missing"); } String assetId = argument.getString("asset_id"); ledger.get(assetId); ledger.put(assetId, argument.getJsonObject("data")); return null; }  @Override JsonObject invoke(Ledger ledger, JsonObject argument, Optional<JsonObject> property);  }### Answer:
@Test public void invoke_AssetIdAndDataGiven_ShouldResultInSuccess() { JsonObject argument = Json.createObjectBuilder() .add("asset_id", ASSET_ID) .add("data", Json.createObjectBuilder().build()) .build(); JsonObject result = contract.invoke(ledger, argument, Optional.empty()); assertThat(result).isEqualTo(null); }
@Test public void invoke_AssetIdNotGiven_ShouldThrowContractContextException() { JsonObject argument = Json.createObjectBuilder().build(); assertThatThrownBy(() -> contract.invoke(ledger, argument, Optional.empty())) .isInstanceOf(ContractContextException.class); }