Use reply-with-successful where appropriate
[jFCPlib.git] / src / test / java / net / pterodactylus / fcp / quelaton / DefaultFcpClientTest.java
index d0ae0e5..77573c0 100644 (file)
@@ -1605,14 +1605,8 @@ public class DefaultFcpClientTest {
                                        .uri("KSK@foo.txt")
                                        .execute();
                                connectNode();
-                               List<String> lines = fcpServer.collectUntil(is("Hello"));
-                               String identifier = extractIdentifier(lines);
-                               fcpServer.writeLine(
-                                       "URIGenerated",
-                                       "Identifier=" + identifier,
-                                       "URI=KSK@foo.txt",
-                                       "EndMessage"
-                               );
+                               readMessage("Hello", this::matchesDirectClientPut);
+                               replyWithGeneratedUri();
                                replyWithPutSuccessful(identifier);
                                assertThat(key.get().get().getKey(), is("KSK@foo.txt"));
                                assertThat(generatedKeys, contains("KSK@foo.txt"));
@@ -1651,6 +1645,15 @@ public class DefaultFcpClientTest {
                        );
                }
 
+               private void replyWithGeneratedUri() throws IOException {
+                       fcpServer.writeLine(
+                               "URIGenerated",
+                               "Identifier=" + identifier,
+                               "URI=KSK@foo.txt",
+                               "EndMessage"
+                       );
+               }
+
                private void replyWithSimpleProgress(
                        int total, int required, int failed, int fatallyFailed, int succeeded, int lastProgress,
                        boolean finalizedTotal, int minSuccessFetchBlocks) throws IOException {
@@ -1695,8 +1698,8 @@ public class DefaultFcpClientTest {
                                connectAndAssert(() -> matchesClientPutDiskDir("Verbosity=1"));
                                replyWithSimpleProgress(1, 2, 3, 4, 5, 6, true, 8);
                                replyWithSimpleProgress(11, 12, 13, 14, 15, 16, false, 18);
-                               fcpServer.writeLine("PutSuccessful", "Identifier=" + identifier, "URI=CHK@abc", "EndMessage");
-                               assertThat(key.get().get().getKey(), is("CHK@abc"));
+                               replyWithPutSuccessful(identifier);
+                               assertThat(key.get().get().getKey(), is("KSK@foo.txt"));
                                assertThat(requestProgress, contains(
                                        isRequestProgress(1, 2, 3, 4, 5, 6, true, 8),
                                        isRequestProgress(11, 12, 13, 14, 15, 16, false, 18)