mirror of
https://github.com/czp3009/bilibili-api.git
synced 2025-02-19 20:50:28 +08:00
添加对 获奖记录 的测试
This commit is contained in:
parent
72ea245c7f
commit
ee3460bb95
@ -0,0 +1,26 @@
|
||||
package com.hiczp.bilibili.api.interceptor;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Response;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class PrintResponseBodyInterceptor implements Interceptor {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PrintResponseBodyInterceptor.class);
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
Response response = chain.proceed(chain.request());
|
||||
|
||||
JsonObject jsonObject = InterceptorHelper.getJsonInBody(response);
|
||||
LOGGER.info(GSON.toJson(jsonObject));
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
@ -220,6 +220,8 @@ public interface LiveService {
|
||||
//TODO 取消佩戴
|
||||
|
||||
//TODO 获奖记录
|
||||
@GET("AppUser/awards")
|
||||
Call<AwardsEntity> getAwards();
|
||||
|
||||
//瓜子商店
|
||||
//侧拉抽屉 -> 直播中心 -> 瓜子商店 -> 银瓜子兑换 -> 硬币银瓜子互换 -> 兑换硬币
|
||||
|
@ -0,0 +1,84 @@
|
||||
package com.hiczp.bilibili.api.live.entity;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AwardsEntity {
|
||||
/**
|
||||
* code : 0
|
||||
* message : OK
|
||||
* data : {"list":[],"use_count":0,"count":0}
|
||||
*/
|
||||
|
||||
@SerializedName("code")
|
||||
private int code;
|
||||
@SerializedName("message")
|
||||
private String message;
|
||||
@SerializedName("data")
|
||||
private Data data;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Data getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Data data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static class Data {
|
||||
/**
|
||||
* list : []
|
||||
* use_count : 0
|
||||
* count : 0
|
||||
*/
|
||||
|
||||
@SerializedName("use_count")
|
||||
private int useCount;
|
||||
@SerializedName("count")
|
||||
private int count;
|
||||
@SerializedName("list")
|
||||
private List<JsonObject> list;
|
||||
|
||||
public int getUseCount() {
|
||||
return useCount;
|
||||
}
|
||||
|
||||
public void setUseCount(int useCount) {
|
||||
this.useCount = useCount;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public List<?> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setList(List<JsonObject> list) {
|
||||
this.list = list;
|
||||
}
|
||||
}
|
||||
}
|
21
src/test/java/com/hiczp/bilibili/api/test/GetAwardsTest.java
Normal file
21
src/test/java/com/hiczp/bilibili/api/test/GetAwardsTest.java
Normal file
@ -0,0 +1,21 @@
|
||||
package com.hiczp.bilibili.api.test;
|
||||
|
||||
import com.hiczp.bilibili.api.BilibiliAPI;
|
||||
import com.hiczp.bilibili.api.interceptor.PrintResponseBodyInterceptor;
|
||||
import okhttp3.logging.HttpLoggingInterceptor;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class GetAwardsTest {
|
||||
private static final BilibiliAPI BILIBILI_API = Config.getBilibiliAPI();
|
||||
|
||||
@Test
|
||||
public void getAwards() throws Exception {
|
||||
BILIBILI_API
|
||||
.getLiveService(Collections.singletonList(new PrintResponseBodyInterceptor()), HttpLoggingInterceptor.Level.BODY)
|
||||
.getAwards()
|
||||
.execute()
|
||||
.body();
|
||||
}
|
||||
}
|
@ -23,6 +23,7 @@ import java.nio.file.Paths;
|
||||
SecurityHelperTest.class,
|
||||
AuthenticatorTest.class,
|
||||
WebAPITest.class,
|
||||
GetAwardsTest.class,
|
||||
LogoutTest.class
|
||||
})
|
||||
public class RuleSuite {
|
||||
|
Loading…
Reference in New Issue
Block a user