harbor run -t openthoughts/tasktrove-exp-rpt-methods2test-large-v3-methods2test-1761harbor download openthoughts/tasktrove-exp-rpt-methods2test-large-v3-methods2test-1761Implement Java sources under /app/src/main/java/ so that the JUnit 5 test at /tests/TestSolution.java compiles and passes. The verifier runs mvn test against the project rooted at /app/ (see /tests/pom.xml). Java 17 is the target.
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;
public class TestSolution {
@Test public void networkStatusTest() throws Exception { TestSpace ts = prepareTestSpace(); ts.nodes.forEach(n-> { try { n.config.getAddressesWhiteList().add(TestKeys.publicKey(1).getLongAddress()); } catch (EncryptionError encryptionError) { encryptionError.printStackTrace(); } }); Client client = new Client("./src/test_node_config_v2/test_node_config_v2.json",System.getProperty("java.io.tmpdir"),TestKeys.privateKey(1)); HashId id1 = HashId.createRandom(); ts.nodes.forEach(n->n.node.getLedger().findOrCreate(id1).setState(ItemState.APPROVED).save()); assertTrue(client.isApprovedByNetwork(id1,0.9,3000)); HashId id2 = HashId.createRandom(); for(int i = 0; i < ts.nodes.size();i++) { ts.nodes.get(i).node.getLedger().findOrCreate(id2).setState(i==0?ItemState.DECLINED:ItemState.APPROVED); } for(int i = 0; i < 10;i++) { assertFalse(client.isApprovedByNetwork(id2, 0.8, 3000)); } ts.shutdown(); try { client.isApprovedByNetwork(HashId.createRandom(),0.1,3000); } catch (ClientError e) { System.out.println(e.getErrorRecord()); assertEquals(e.getErrorRecord().getError(), Errors.COMMAND_PENDING); } }
}
Your code must define (or pull in via a properly configured classpath) the symbols below. JUnit 5 itself is already on the test classpath via pom.xml, so you only need to provide the non-JUnit symbols.
Top-level types/constants the test uses (not Java/JUnit builtins):
APPROVEDCOMMAND_PENDINGClientClientErrorDECLINEDEncryptionErrorErrorsHashIdItemStateTestKeysTestSpacePublic API the test invokes (Type.method(...)):
TestKeys.publicKey(...)TestKeys.privateKey(...)HashId.createRandom(...)/app/src/main/java/ (matching pom.xml's sourceDirectory). Use package directories for fully-qualified types (e.g. /app/src/main/java/org/example/Foo.java for org.example.Foo).package line), so any class it references by bare name (e.g. Solution, NamingUtils, etc.) must also live in the default package (directly under /app/src/main/java/).singletonList(...) or assertThat(...) that aren't covered by the two import lines shown above, add the missing import static ...; to your own source files (the test file itself is read-only).mvn test from /app/. Maven dependencies beyond JUnit 5 (already in /tests/pom.xml) need to be declared in your own /app/pom.xml if you choose to bring in third-party libraries; otherwise implement the referenced classes yourself./tests/TestSolution.java or /tests/pom.xml — they are the spec.