Skip to content

Commit

Permalink
PROJ-10957 sdk更新
Browse files Browse the repository at this point in the history
  • Loading branch information
locketliu committed Dec 5, 2024
1 parent a64818b commit f18fde1
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ public GetCurrentPositionResponse getCurrentPosition(String symbol) {
return execute(spotPoloPrivateApiService.getCurrentPosition(symbol));
}

public GetLeveragesResponse getLeverages(String symbol,String mgnModel) {
return execute(spotPoloPrivateApiService.getLeverages(symbol,mgnModel));
}

public GetPositionHistoryResponse getPositionHistory(String symbol,
String mgnMode,
Expand Down Expand Up @@ -191,6 +194,9 @@ public SetLeverageResponse setLeverage(SetLeverageRequest request) {
return execute(spotPoloPrivateApiService.setLeverage(request));
}

public GetModeResponse getPositionMode() {
return execute(spotPoloPrivateApiService.getPositionMode());
}

public GetOrderBookResponse getOrderBook(String symbol,
String scale,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void testgetCurrentPosition() throws IOException {

@Test
void testAdjustMargin() throws IOException {
AdjustMarginRequest request = AdjustMarginRequest.builder().symbol("BTC").type("ADD").amt("10").build();
AdjustMarginRequest request = AdjustMarginRequest.builder().symbol("BTC").type("ADD").amt("10").posSide("null").build();

AdjustMarginResponse atr = new AdjustMarginResponse();
atr.getData().setSymbol("test");
Expand All @@ -315,6 +315,7 @@ void testAdjustMargin() throws IOException {
verify(spotPoloPrivateApiService, times(1)).adjustMargin(request);
assertEquals("test", response.getData().getSymbol());
}

// @Test
// void testSwitchCross() throws IOException {
// SwitchCrossRequest request = SwitchCrossRequest.builder().symbol("BTC").mgnMode("CROSS").build();
Expand Down Expand Up @@ -365,7 +366,7 @@ void testAdjustMargin() throws IOException {

@Test
void testSetLeverage() throws IOException {
SetLeverageRequest request = SetLeverageRequest.builder().symbol("BTC").lever("7").build();
SetLeverageRequest request = SetLeverageRequest.builder().symbol("BTC").lever("7").mgnMode("").posSide("").build();

SetLeverageResponse atr = new SetLeverageResponse();
atr.getData().setSymbol("test");
Expand All @@ -379,6 +380,56 @@ void testSetLeverage() throws IOException {
assertEquals("test", response.getData().getSymbol());
}

@Test
void testGetLeverages() throws IOException {

GetLeveragesResponse atr = new GetLeveragesResponse();
GetLeveragesResponse.GetLeverages getLeverages = new GetLeveragesResponse.GetLeverages();
getLeverages.setSymbol("test");
atr.getData().add(getLeverages);

Call<GetLeveragesResponse> call = mock(Call.class);
when(call.execute()).thenReturn(Response.success(atr));

when(spotPoloPrivateApiService.getLeverages("test","mgnMode")).thenReturn(call);
GetLeveragesResponse response = spotPoloRestClient.getLeverages("test","mgnMode");
verify(spotPoloPrivateApiService, times(1)).getLeverages("test","mgnMode");
assertEquals("test", response.getData().get(0).getSymbol());
}

@Test
void testSetPositionMode() throws IOException {

SetModeRequest request = SetModeRequest.builder().posMode("test").build();
SetModeResponse atr = new SetModeResponse();
// atr.getData()("test");

Call<SetModeResponse> call = mock(Call.class);
when(call.execute()).thenReturn(Response.success(atr));

when(spotPoloPrivateApiService.setPositionMode(request)).thenReturn(call);
GetModeResponse response = spotPoloRestClient.getPositionMode();
verify(spotPoloPrivateApiService, times(1)).getPositionMode();
assertEquals("test", response.getData().getPosMode());
}

@Test
void testGetPositionMode() throws IOException {

GetModeResponse atr = new GetModeResponse();
GetModeResponse.PositionMode data = new GetModeResponse.PositionMode();
data.setPosMode("test");
atr.setData(data);

Call<GetModeResponse> call = mock(Call.class);
when(call.execute()).thenReturn(Response.success(atr));

when(spotPoloPrivateApiService.getPositionMode()).thenReturn(call);
GetModeResponse response = spotPoloRestClient.getPositionMode();
verify(spotPoloPrivateApiService, times(1)).getPositionMode();
assertEquals("test", response.getData().getPosMode());
}

@Test
void testGetOrderBook() throws IOException {
// SwitchCrossRequest request = SwitchCrossRequest.builder().build();
Expand Down

0 comments on commit f18fde1

Please sign in to comment.