From f28ac18d2f8f97bac3ce276eba67061c37d1746d Mon Sep 17 00:00:00 2001 From: reeyur Date: Thu, 12 Mar 2020 16:19:07 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E6=96=B0=E5=A2=9EgetMockDetailById?= =?UTF-8?q?=E5=92=8CMock=E7=B1=BB=E3=80=81MockDetail=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 14 +++++++ pom.xml | 6 +++ .../java/com/meituan/lyrebird/Lyrebird.java | 11 ++++++ .../lyrebird/client/LyrebirdClient.java | 15 ++++++++ .../lyrebird/client/LyrebirdService.java | 3 ++ .../com/meituan/lyrebird/client/api/Mock.java | 18 +++++++++ .../lyrebird/client/api/MockDetail.java | 37 +++++++++++++++++++ .../meituan/lyrebird/test/TestFunctional.java | 18 +++++++++ 8 files changed, 122 insertions(+) create mode 100644 src/main/java/com/meituan/lyrebird/client/api/Mock.java create mode 100644 src/main/java/com/meituan/lyrebird/client/api/MockDetail.java diff --git a/README.md b/README.md index b94f068..159a876 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ - [TestNG](#TestNG) - [Junit4](#Junit4) - [取消激活](#取消激活) + - [读取Mock数据](#读取Mock数据) - [获取网络数据信息](#获取网络数据信息) - [获取 flow List](#获取-flow-List) - [获取 flow ID](#获取-flow-ID) @@ -217,6 +218,19 @@ Lyrebird lyrebird = new Lyrebird(); lyrebird.deactivate(); ``` +#### 读取Mock数据 + +调用 getMockDetailById(String groupID) 方法可以获取该数据组的 Mock 数据详情 +```java +Lyrebird lyrebird = new Lyrebird(); + +MockDetail mockDetail = lyrebird.getMockDetailById(String cfa0c589-8ef0-4885-b4f4-b9688c5af0d5); +// 读取Mock数据名 +String mockDataName = mockDetail.getName(); +// 读取Mock Response (注意:Lyrebird服务端返回的是一个 Json 字符串,并不是一个 Json 对象) +String mockDataResponse = mockDetail.getResponseData(); +``` + ### 获取网络数据信息 flow 示例 diff --git a/pom.xml b/pom.xml index c376de6..adaa400 100644 --- a/pom.xml +++ b/pom.xml @@ -162,6 +162,12 @@ junit 4.12 + + org.hamcrest + hamcrest-all + 1.3 + test + com.squareup.okhttp3 mockwebserver diff --git a/src/main/java/com/meituan/lyrebird/Lyrebird.java b/src/main/java/com/meituan/lyrebird/Lyrebird.java index 274e9fe..5190f92 100644 --- a/src/main/java/com/meituan/lyrebird/Lyrebird.java +++ b/src/main/java/com/meituan/lyrebird/Lyrebird.java @@ -142,6 +142,17 @@ public EventDetail[] getEventList(String channel) throws LyrebirdClientException return client.getEventList(channel).getEvents(); } + /** + * Get mock details by group id + * + * @param groupId + * @return + * @throws LyrebirdClientException + */ + public MockDetail getMockDetailById(String groupId) throws LyrebirdClientException { + return client.getMockData(groupId).getMockDetail(); + } + /** * Get an object of socket io * diff --git a/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java b/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java index bc2579c..853beb6 100644 --- a/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java +++ b/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java @@ -182,6 +182,21 @@ public Events getEventList(String channel) throws LyrebirdClientException { } } + /** + * get mock data by group id + * + * @param groupId mock group id + * @return + * @throws LyrebirdClientException + */ + public Mock getMockData(String groupId) throws LyrebirdClientException { + try{ + return lyrebirdService.getMockData(groupId).execute().body(); + } catch (IOException e) { + throw new LyrebirdClientException("Catch exception while find mock response data by group id ", e); + } + } + /** * Get an object of socket io * diff --git a/src/main/java/com/meituan/lyrebird/client/LyrebirdService.java b/src/main/java/com/meituan/lyrebird/client/LyrebirdService.java index 4e86746..4166975 100644 --- a/src/main/java/com/meituan/lyrebird/client/LyrebirdService.java +++ b/src/main/java/com/meituan/lyrebird/client/LyrebirdService.java @@ -27,4 +27,7 @@ public interface LyrebirdService { @GET("api/event/{channel}") Call getEventList(@Path("channel") String channel); + + @GET("api/data/{groupId}") + Call getMockData(@Path("groupId") String groupId); } diff --git a/src/main/java/com/meituan/lyrebird/client/api/Mock.java b/src/main/java/com/meituan/lyrebird/client/api/Mock.java new file mode 100644 index 0000000..35f1ca9 --- /dev/null +++ b/src/main/java/com/meituan/lyrebird/client/api/Mock.java @@ -0,0 +1,18 @@ +package com.meituan.lyrebird.client.api; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class Mock { + @JsonProperty("data") + private MockDetail mockDetail; + + public MockDetail getMockDetail() { + return mockDetail; + } + + public void setMockDetail(MockDetail mockDetail) { + this.mockDetail = mockDetail; + } +} diff --git a/src/main/java/com/meituan/lyrebird/client/api/MockDetail.java b/src/main/java/com/meituan/lyrebird/client/api/MockDetail.java new file mode 100644 index 0000000..5c33bc6 --- /dev/null +++ b/src/main/java/com/meituan/lyrebird/client/api/MockDetail.java @@ -0,0 +1,37 @@ +package com.meituan.lyrebird.client.api; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Map; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class MockDetail { + private String id; + private String name; + private String responseData; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @JsonProperty("response") + public void setResponseData(Map response) { + this.responseData = response.get("data").toString(); + } + + public String getResponseData() { + return responseData; + } +} diff --git a/src/test/java/com/meituan/lyrebird/test/TestFunctional.java b/src/test/java/com/meituan/lyrebird/test/TestFunctional.java index 5d78092..83f7ba0 100644 --- a/src/test/java/com/meituan/lyrebird/test/TestFunctional.java +++ b/src/test/java/com/meituan/lyrebird/test/TestFunctional.java @@ -1,10 +1,12 @@ package com.meituan.lyrebird.test; import com.google.gson.Gson; +import com.jayway.jsonpath.Configuration; import com.jayway.jsonpath.JsonPath; import com.meituan.lyrebird.Lyrebird; import com.meituan.lyrebird.client.api.*; import com.meituan.lyrebird.client.exceptions.LyrebirdClientException; +import java.util.List; import okhttp3.mockwebserver.*; import org.junit.*; @@ -167,4 +169,20 @@ public void testEventList() throws LyrebirdClientException, InterruptedException Assert.assertEquals("com.lyrebird.java.client", JsonPath.parse(eventList[0].getContent()).read("$.page")); Assert.assertEquals("81825f43-5fd6-45f7-b22b-83493ca99e46", eventList[0].getEventID()); } + + @Test + public void testMockDetails() throws LyrebirdClientException { + this.mockServer.enqueue( + new MockResponse() + .setBody( + "{\"code\": 1000,\"data\": {\"id\": \"cfa0c589-8ef0-4885-b4f4-b9688c5af0d5\", \"name\": \"test-data\", \"response\": {\"data\": \"[{\\\"type\\\": \\\"scheme\\\", \\\"info\\\":{\\\"value\\\": \\\"test://www.lyrebird.java.sdk.com\\\"}, \\\"desc\\\": \\\"The scheme of target page\\\"}]\"}}, \"message\": \"success\"}")); + + MockDetail mockDetail = this.lyrebird.getMockDetailById("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5"); + Assert.assertEquals("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5", mockDetail.getId()); + Assert.assertEquals("test-data", mockDetail.getName()); + + List urlScheme = JsonPath.parse(mockDetail.getResponseData()).read("$[?(@.type == 'scheme')].info.value"); + Assert.assertEquals(1, urlScheme.size()); + Assert.assertEquals("test://www.lyrebird.java.sdk.com", urlScheme.get(0)); + } } From 96d298825b5278f969d36c99eb55b34e21cd32dd Mon Sep 17 00:00:00 2001 From: reeyur Date: Thu, 12 Mar 2020 16:21:00 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 159a876..e4336a3 100644 --- a/README.md +++ b/README.md @@ -224,7 +224,7 @@ lyrebird.deactivate(); ```java Lyrebird lyrebird = new Lyrebird(); -MockDetail mockDetail = lyrebird.getMockDetailById(String cfa0c589-8ef0-4885-b4f4-b9688c5af0d5); +MockDetail mockDetail = lyrebird.getMockDetailById("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5"); // 读取Mock数据名 String mockDataName = mockDetail.getName(); // 读取Mock Response (注意:Lyrebird服务端返回的是一个 Json 字符串,并不是一个 Json 对象) From 85f0da8a65b8ec59b1778029aca9b8eaf887ae36 Mon Sep 17 00:00:00 2001 From: reeyur Date: Thu, 12 Mar 2020 16:24:13 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index adaa400..6df377e 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.github.meituan-dianping.lyrebird.sdk lyrebird-java-client - 1.1.0 + 1.1.1 lyrebird-java-client https://github.com/Meituan-Dianping/lyrebird-java-client From 0c84bff341319ea2b9908a66bae142ccb6338aaf Mon Sep 17 00:00:00 2001 From: reeyur Date: Thu, 12 Mar 2020 17:15:34 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9Code=20Review=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- .../java/com/meituan/lyrebird/Lyrebird.java | 8 ++-- .../lyrebird/client/LyrebirdClient.java | 10 ++--- .../lyrebird/client/LyrebirdService.java | 4 +- .../lyrebird/client/api/LBMockData.java | 32 ++++++++++++++++ .../com/meituan/lyrebird/client/api/Mock.java | 18 --------- .../lyrebird/client/api/MockDetail.java | 37 ------------------- .../meituan/lyrebird/test/TestFunctional.java | 9 ++--- 8 files changed, 49 insertions(+), 73 deletions(-) create mode 100644 src/main/java/com/meituan/lyrebird/client/api/LBMockData.java delete mode 100644 src/main/java/com/meituan/lyrebird/client/api/Mock.java delete mode 100644 src/main/java/com/meituan/lyrebird/client/api/MockDetail.java diff --git a/README.md b/README.md index e4336a3..ec88a77 100644 --- a/README.md +++ b/README.md @@ -220,11 +220,11 @@ lyrebird.deactivate(); #### 读取Mock数据 -调用 getMockDetailById(String groupID) 方法可以获取该数据组的 Mock 数据详情 +调用 getMockData(String dataId) 方法可以获取该数据组的 Mock 数据详情 ```java Lyrebird lyrebird = new Lyrebird(); -MockDetail mockDetail = lyrebird.getMockDetailById("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5"); +MockDetail mockDetail = lyrebird.getMockData("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5"); // 读取Mock数据名 String mockDataName = mockDetail.getName(); // 读取Mock Response (注意:Lyrebird服务端返回的是一个 Json 字符串,并不是一个 Json 对象) diff --git a/src/main/java/com/meituan/lyrebird/Lyrebird.java b/src/main/java/com/meituan/lyrebird/Lyrebird.java index 5190f92..58e9b75 100644 --- a/src/main/java/com/meituan/lyrebird/Lyrebird.java +++ b/src/main/java/com/meituan/lyrebird/Lyrebird.java @@ -143,14 +143,14 @@ public EventDetail[] getEventList(String channel) throws LyrebirdClientException } /** - * Get mock details by group id + * Get mock data by data id * - * @param groupId + * @param dataId mock data id * @return * @throws LyrebirdClientException */ - public MockDetail getMockDetailById(String groupId) throws LyrebirdClientException { - return client.getMockData(groupId).getMockDetail(); + public LBMockData getMockData(String dataId) throws LyrebirdClientException { + return client.getMockData(dataId); } /** diff --git a/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java b/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java index 853beb6..430c575 100644 --- a/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java +++ b/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java @@ -183,17 +183,17 @@ public Events getEventList(String channel) throws LyrebirdClientException { } /** - * get mock data by group id + * get mock data by data id * - * @param groupId mock group id + * @param dataId mock data id * @return * @throws LyrebirdClientException */ - public Mock getMockData(String groupId) throws LyrebirdClientException { + public LBMockData getMockData(String dataId) throws LyrebirdClientException { try{ - return lyrebirdService.getMockData(groupId).execute().body(); + return lyrebirdService.getMockData(dataId).execute().body(); } catch (IOException e) { - throw new LyrebirdClientException("Catch exception while find mock response data by group id ", e); + throw new LyrebirdClientException("Catch exception while get mock response data by data id ", e); } } diff --git a/src/main/java/com/meituan/lyrebird/client/LyrebirdService.java b/src/main/java/com/meituan/lyrebird/client/LyrebirdService.java index 4166975..a6b989a 100644 --- a/src/main/java/com/meituan/lyrebird/client/LyrebirdService.java +++ b/src/main/java/com/meituan/lyrebird/client/LyrebirdService.java @@ -28,6 +28,6 @@ public interface LyrebirdService { @GET("api/event/{channel}") Call getEventList(@Path("channel") String channel); - @GET("api/data/{groupId}") - Call getMockData(@Path("groupId") String groupId); + @GET("api/data/{dataId}") + Call getMockData(@Path("dataId") String dataId); } diff --git a/src/main/java/com/meituan/lyrebird/client/api/LBMockData.java b/src/main/java/com/meituan/lyrebird/client/api/LBMockData.java new file mode 100644 index 0000000..0f69ec2 --- /dev/null +++ b/src/main/java/com/meituan/lyrebird/client/api/LBMockData.java @@ -0,0 +1,32 @@ +package com.meituan.lyrebird.client.api; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.jayway.jsonpath.JsonPath; +import java.util.Map; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class LBMockData extends BaseResponse { + @JsonProperty("data") + private Map data; + + public String getId() { + return data.get("id").toString(); + } + + public String getName() { + return data.get("name").toString(); + } + + public String getResponseData() { + return JsonPath.parse(data.get("response")).read("$.data"); + } + + public Map getData() { + return data; + } + + public void setData(Map data) { + this.data = data; + } +} diff --git a/src/main/java/com/meituan/lyrebird/client/api/Mock.java b/src/main/java/com/meituan/lyrebird/client/api/Mock.java deleted file mode 100644 index 35f1ca9..0000000 --- a/src/main/java/com/meituan/lyrebird/client/api/Mock.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.meituan.lyrebird.client.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class Mock { - @JsonProperty("data") - private MockDetail mockDetail; - - public MockDetail getMockDetail() { - return mockDetail; - } - - public void setMockDetail(MockDetail mockDetail) { - this.mockDetail = mockDetail; - } -} diff --git a/src/main/java/com/meituan/lyrebird/client/api/MockDetail.java b/src/main/java/com/meituan/lyrebird/client/api/MockDetail.java deleted file mode 100644 index 5c33bc6..0000000 --- a/src/main/java/com/meituan/lyrebird/client/api/MockDetail.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.meituan.lyrebird.client.api; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.util.Map; - -@JsonIgnoreProperties(ignoreUnknown = true) -public class MockDetail { - private String id; - private String name; - private String responseData; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @JsonProperty("response") - public void setResponseData(Map response) { - this.responseData = response.get("data").toString(); - } - - public String getResponseData() { - return responseData; - } -} diff --git a/src/test/java/com/meituan/lyrebird/test/TestFunctional.java b/src/test/java/com/meituan/lyrebird/test/TestFunctional.java index 83f7ba0..88db11a 100644 --- a/src/test/java/com/meituan/lyrebird/test/TestFunctional.java +++ b/src/test/java/com/meituan/lyrebird/test/TestFunctional.java @@ -1,7 +1,6 @@ package com.meituan.lyrebird.test; import com.google.gson.Gson; -import com.jayway.jsonpath.Configuration; import com.jayway.jsonpath.JsonPath; import com.meituan.lyrebird.Lyrebird; import com.meituan.lyrebird.client.api.*; @@ -177,11 +176,11 @@ public void testMockDetails() throws LyrebirdClientException { .setBody( "{\"code\": 1000,\"data\": {\"id\": \"cfa0c589-8ef0-4885-b4f4-b9688c5af0d5\", \"name\": \"test-data\", \"response\": {\"data\": \"[{\\\"type\\\": \\\"scheme\\\", \\\"info\\\":{\\\"value\\\": \\\"test://www.lyrebird.java.sdk.com\\\"}, \\\"desc\\\": \\\"The scheme of target page\\\"}]\"}}, \"message\": \"success\"}")); - MockDetail mockDetail = this.lyrebird.getMockDetailById("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5"); - Assert.assertEquals("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5", mockDetail.getId()); - Assert.assertEquals("test-data", mockDetail.getName()); + LBMockData lbMockData = this.lyrebird.getMockData("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5"); + Assert.assertEquals("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5", lbMockData.getId()); + Assert.assertEquals("test-data", lbMockData.getName()); - List urlScheme = JsonPath.parse(mockDetail.getResponseData()).read("$[?(@.type == 'scheme')].info.value"); + List urlScheme = JsonPath.parse(lbMockData.getResponseData()).read("$[?(@.type == 'scheme')].info.value"); Assert.assertEquals(1, urlScheme.size()); Assert.assertEquals("test://www.lyrebird.java.sdk.com", urlScheme.get(0)); } From 4c7b9f765ee5c2b36d82490e8a44ad3bbab8e8c9 Mon Sep 17 00:00:00 2001 From: reeyur Date: Thu, 12 Mar 2020 17:16:42 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ec88a77..54dc8e6 100644 --- a/README.md +++ b/README.md @@ -224,11 +224,11 @@ lyrebird.deactivate(); ```java Lyrebird lyrebird = new Lyrebird(); -MockDetail mockDetail = lyrebird.getMockData("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5"); +LBMockData lbMockData = lyrebird.getMockData("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5"); // 读取Mock数据名 -String mockDataName = mockDetail.getName(); +String mockDataName = lbMockData.getName(); // 读取Mock Response (注意:Lyrebird服务端返回的是一个 Json 字符串,并不是一个 Json 对象) -String mockDataResponse = mockDetail.getResponseData(); +String mockDataResponse = lbMockData.getResponseData(); ``` ### 获取网络数据信息 From 7b69f60362dcf35f8e9a06a36c7ac0b76c566956 Mon Sep 17 00:00:00 2001 From: reeyur Date: Thu, 12 Mar 2020 17:19:52 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/meituan/lyrebird/client/api/LBMockData.java | 2 +- src/test/java/com/meituan/lyrebird/test/TestFunctional.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/meituan/lyrebird/client/api/LBMockData.java b/src/main/java/com/meituan/lyrebird/client/api/LBMockData.java index 0f69ec2..53fb744 100644 --- a/src/main/java/com/meituan/lyrebird/client/api/LBMockData.java +++ b/src/main/java/com/meituan/lyrebird/client/api/LBMockData.java @@ -18,7 +18,7 @@ public String getName() { return data.get("name").toString(); } - public String getResponseData() { + public T getResponseData() { return JsonPath.parse(data.get("response")).read("$.data"); } diff --git a/src/test/java/com/meituan/lyrebird/test/TestFunctional.java b/src/test/java/com/meituan/lyrebird/test/TestFunctional.java index 88db11a..7ae8524 100644 --- a/src/test/java/com/meituan/lyrebird/test/TestFunctional.java +++ b/src/test/java/com/meituan/lyrebird/test/TestFunctional.java @@ -180,7 +180,7 @@ public void testMockDetails() throws LyrebirdClientException { Assert.assertEquals("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5", lbMockData.getId()); Assert.assertEquals("test-data", lbMockData.getName()); - List urlScheme = JsonPath.parse(lbMockData.getResponseData()).read("$[?(@.type == 'scheme')].info.value"); + List urlScheme = JsonPath.parse(lbMockData.getResponseData().toString()).read("$[?(@.type == 'scheme')].info.value"); Assert.assertEquals(1, urlScheme.size()); Assert.assertEquals("test://www.lyrebird.java.sdk.com", urlScheme.get(0)); } From 851c40d3f60cdfe6ac8d9cd87f8fb51593b80e2e Mon Sep 17 00:00:00 2001 From: reeyur Date: Thu, 12 Mar 2020 17:20:45 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 54dc8e6..032b232 100644 --- a/README.md +++ b/README.md @@ -228,7 +228,7 @@ LBMockData lbMockData = lyrebird.getMockData("cfa0c589-8ef0-4885-b4f4-b9688c5af0 // 读取Mock数据名 String mockDataName = lbMockData.getName(); // 读取Mock Response (注意:Lyrebird服务端返回的是一个 Json 字符串,并不是一个 Json 对象) -String mockDataResponse = lbMockData.getResponseData(); +Object mockDataResponse = lbMockData.getResponseData(); ``` ### 获取网络数据信息 From 6a0fed54f150bef079c2b2a01a79d9a1cf28f458 Mon Sep 17 00:00:00 2001 From: reeyur Date: Thu, 12 Mar 2020 17:24:24 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=96=B9=E6=B3=95=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/com/meituan/lyrebird/test/TestFunctional.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/meituan/lyrebird/test/TestFunctional.java b/src/test/java/com/meituan/lyrebird/test/TestFunctional.java index 7ae8524..df04354 100644 --- a/src/test/java/com/meituan/lyrebird/test/TestFunctional.java +++ b/src/test/java/com/meituan/lyrebird/test/TestFunctional.java @@ -170,7 +170,7 @@ public void testEventList() throws LyrebirdClientException, InterruptedException } @Test - public void testMockDetails() throws LyrebirdClientException { + public void testLBMockData() throws LyrebirdClientException { this.mockServer.enqueue( new MockResponse() .setBody( From ab54d8af60d4b02d2bdca98fc48668cb6262a971 Mon Sep 17 00:00:00 2001 From: reeyur Date: Thu, 12 Mar 2020 17:56:02 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9Codacy/PR=20Quality=20Rev?= =?UTF-8?q?iew?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/meituan/lyrebird/test/TestFunctional.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/meituan/lyrebird/test/TestFunctional.java b/src/test/java/com/meituan/lyrebird/test/TestFunctional.java index df04354..c1d67ed 100644 --- a/src/test/java/com/meituan/lyrebird/test/TestFunctional.java +++ b/src/test/java/com/meituan/lyrebird/test/TestFunctional.java @@ -177,11 +177,11 @@ public void testLBMockData() throws LyrebirdClientException { "{\"code\": 1000,\"data\": {\"id\": \"cfa0c589-8ef0-4885-b4f4-b9688c5af0d5\", \"name\": \"test-data\", \"response\": {\"data\": \"[{\\\"type\\\": \\\"scheme\\\", \\\"info\\\":{\\\"value\\\": \\\"test://www.lyrebird.java.sdk.com\\\"}, \\\"desc\\\": \\\"The scheme of target page\\\"}]\"}}, \"message\": \"success\"}")); LBMockData lbMockData = this.lyrebird.getMockData("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5"); - Assert.assertEquals("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5", lbMockData.getId()); - Assert.assertEquals("test-data", lbMockData.getName()); + assertEquals("cfa0c589-8ef0-4885-b4f4-b9688c5af0d5", lbMockData.getId()); + assertEquals("test-data", lbMockData.getName()); List urlScheme = JsonPath.parse(lbMockData.getResponseData().toString()).read("$[?(@.type == 'scheme')].info.value"); - Assert.assertEquals(1, urlScheme.size()); - Assert.assertEquals("test://www.lyrebird.java.sdk.com", urlScheme.get(0)); + assertEquals(1, urlScheme.size()); + assertEquals("test://www.lyrebird.java.sdk.com", urlScheme.get(0)); } }