Skip to content

Commit 09d6060

Browse files
fix(responsetemplate/mgr): improve description for 423 Empty API response
1 parent f183d1f commit 09d6060

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/main/java/net/hexonet/apiconnector/ResponseTemplateManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ private ResponseTemplateManager() {
2424
this.templates = new HashMap<String, String>();
2525
this.templates.put("404", this.generateTemplate("421", "Page not found"));
2626
this.templates.put("500", this.generateTemplate("500", "Internal server error"));
27-
this.templates.put("empty", this.generateTemplate("423", "Empty API response"));
27+
this.templates.put("empty", this.generateTemplate("423",
28+
"Empty API response. Probably unreachable API end point"));
2829
this.templates.put("error", this.generateTemplate("421",
2930
"Command failed due to server error. Client should try again"));
3031
this.templates.put("expired", this.generateTemplate("530", "SESSION NOT FOUND"));

src/test/java/net/hexonet/apiconnector/ResponseTemplateTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public class ResponseTemplateTest {
1515
public void constructorVars() {
1616
ResponseTemplate tpl = new ResponseTemplate("");
1717
assertEquals(423, tpl.getCode());
18-
assertEquals("Empty API response", tpl.getDescription());
18+
assertEquals("Empty API response. Probably unreachable API end point",
19+
tpl.getDescription());
1920
}
2021

2122
/**
@@ -26,7 +27,8 @@ public void getHash() {
2627
ResponseTemplate tpl = new ResponseTemplate("");
2728
Map<String, Object> h = tpl.getHash();
2829
assertEquals("423", (String) h.get("CODE"));
29-
assertEquals("Empty API response", (String) h.get("DESCRIPTION"));
30+
assertEquals("Empty API response. Probably unreachable API end point",
31+
(String) h.get("DESCRIPTION"));
3032
}
3133

3234
/**
@@ -44,7 +46,7 @@ public void getQueuetime1() {
4446
@Test
4547
public void getQueuetime2() {
4648
ResponseTemplate tpl = new ResponseTemplate(
47-
"[RESPONSE]\r\ncode=423\r\ndescription=Empty API response\r\nqueuetime=0\r\nEOF\r\n");
49+
"[RESPONSE]\r\ncode=423\r\ndescription=Empty API response. Probably unreachable API end point\r\nqueuetime=0\r\nEOF\r\n");
4850
assertEquals(0, tpl.getQueuetime(), 0);
4951
}
5052

@@ -63,7 +65,7 @@ public void getRuntime1() {
6365
@Test
6466
public void getRuntime2() {
6567
ResponseTemplate tpl = new ResponseTemplate(
66-
"[RESPONSE]\r\ncode=423\r\ndescription=Empty API response\r\nruntime=0.12\r\nEOF\r\n");
68+
"[RESPONSE]\r\ncode=423\r\ndescription=Empty API response. Probably unreachable API end point\r\nruntime=0.12\r\nEOF\r\n");
6769
assertEquals(0.12, tpl.getRuntime(), 0);
6870
}
6971

@@ -82,7 +84,7 @@ public void isPending1() {
8284
@Test
8385
public void isPending2() {
8486
ResponseTemplate tpl = new ResponseTemplate(
85-
"[RESPONSE]\r\ncode=423\r\ndescription=Empty API response\r\npending=1\r\nEOF\r\n");
87+
"[RESPONSE]\r\ncode=423\r\ndescription=Empty API response. Probably unreachable API end point\r\npending=1\r\nEOF\r\n");
8688
assertEquals(true, tpl.isPending());
8789
}
8890
}

0 commit comments

Comments
 (0)