Skip to content

Commit 7f4d660

Browse files
committed
Test case and sample updated to match 2.0 Push API
1 parent b0df202 commit 7f4d660

File tree

4 files changed

+16
-115
lines changed

4 files changed

+16
-115
lines changed
Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,33 @@
11
package com.databox.sdk.sample;
22

3+
import java.io.IOException;
4+
import java.text.SimpleDateFormat;
5+
import java.util.ArrayList;
6+
import java.util.List;
7+
import java.util.Locale;
8+
39
import org.slf4j.Logger;
410
import org.slf4j.LoggerFactory;
511

6-
import com.databox.sdk.DataSink;
7-
import com.databox.sdk.ResponseWrapper;
8-
import com.databox.sdk.impl.DataboxDataSource;
9-
import com.databox.sdk.impl.DataboxSink;
10-
1112
/**
1213
*
1314
* @author Uros Majeric
1415
*
1516
*/
1617
public class DataboxSample {
1718
private static final Logger logger = LoggerFactory.getLogger(DataboxSample.class);
19+
private static final String TOKEN = "my_api_key";
1820

1921
public static void main(String[] args) throws Exception {
20-
String spaceAccessToken = "hd32o1ga8sf7sad0fu9sdufs8440442kj2";
21-
22-
DataSink<DataboxDataSource> sink = new DataboxSink();
23-
24-
DataboxDataSource connection = new DataboxDataSource(spaceAccessToken);
25-
XSLDailyDataProvider xlsxDataProvider = new XSLDailyDataProvider("cycling.xlsx");
26-
connection.addDataProvider(xlsxDataProvider);
27-
28-
// DefaultDataProvider dataProvider = new DefaultDataProvider();
29-
// Calendar c = new GregorianCalendar();
30-
// dataProvider.addKPI(new KPI.Builder().setKey("visits_this_month").setValue(234D).setDate(c.getTime()).build());
31-
// c.add(Calendar.DAY_OF_MONTH, -1);
32-
// dataProvider.addKPI(new KPI.Builder().setKey("visits_this_month").setValue(431D).build());
33-
// connection.addDataProvider(dataProvider);
34-
35-
ResponseWrapper response = sink.push(connection);
36-
if (!response.isSucceeded()) {
37-
logger.error(sink.getLogs(connection));
38-
} else {
39-
logger.info(response.getMessage());
22+
final String TOKEN = "my_api_key";
23+
Databox notification = new Databox(TOKEN);
24+
try {
25+
List<Databox.KPI> kpis = new ArrayList<>();
26+
kpis.add(new Databox.KPI().setKey("my_first_key").setValue(1201.41));
27+
kpis.add(new Databox.KPI().setKey("my_second_key").setValue(8249));
28+
notification.push(kpis);
29+
} catch (Exception e) {
30+
logger.error(e.getLocalizedMessage(), e);
4031
}
4132
}
4233
}

sample/src/main/java/com/databox/sdk/sample/XSLDailyDataProvider.java

Lines changed: 0 additions & 77 deletions
This file was deleted.
-5.36 KB
Binary file not shown.

src/test/java/com/databox/sdk/DataboxTest.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.util.ArrayList;
77
import java.util.List;
88
import java.util.Locale;
9-
import java.util.Map;
109

1110
import junit.framework.TestCase;
1211

@@ -33,16 +32,4 @@ public void testPush() throws IOException {
3332
}
3433
}
3534

36-
public void testPushArray() throws IOException {
37-
Databox notification = new Databox(TOKEN);
38-
try {
39-
List<Databox.KPI> kpis = new ArrayList<>();
40-
kpis.add(new Databox.KPI().setKey("my_first_key").setValue(1201.41));
41-
kpis.add(new Databox.KPI().setKey("my_second_key").setValue(8249));
42-
notification.push(kpis);
43-
} catch (Exception e) {
44-
logger.error(e.getLocalizedMessage(), e);
45-
}
46-
}
47-
4835
}

0 commit comments

Comments
 (0)