Skip to content

Commit b716dc9

Browse files
committed
Test accounting program fix
1 parent e1027d9 commit b716dc9

File tree

2 files changed

+61
-3
lines changed

2 files changed

+61
-3
lines changed

src/com/jacamars/dsp/rtb/tools/TestAccounting.java

+56-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class TestAccounting {
3838
// static String HOST = "btsoomrtb";
3939
// static String HOST = "54.175.237.122";
4040
// static String HOST = "rtb4free.com";
41-
static String winnah = "__COST__/__LAT__/__LON__/__ADID__/__CRID__/__BIDID__/http://__HOST__:8080/contact.html?99201&adid=__ADID__&crid=__CRID__/http://__HOST__:8080/images/320x50.jpg?adid=__ADID__&__BIDID__";
41+
static String winnah = "__COST__/__LAT__/__LON__/__ADID__/__CRID__/__BIDID__";
4242

4343
static String pixel = "/pixel/__EXCHANGE__/__ADID__/__CRID__/__BIDID__/__COST__/__LAT__/__LON__";
4444

@@ -157,8 +157,9 @@ public static void main(String[] args) throws Exception {
157157
BigDecimal wc = new BigDecimal(str);
158158
winCost = winCost.add(wc);
159159
rets.put("uuid", uuid);
160-
String theWin = makeWin(map, theBid, rets, wc.doubleValue());
161-
String rc = post.sendGet(thisWinUrl + theWin, 5000, 5000);
160+
String xwin = (String)theBid.get("nurl");
161+
String theWin = makeWin2(map,xwin,rets,wc.doubleValue());
162+
String rc = post.sendGet(theWin, 5000, 5000);
162163
if (rc == null || rc.length() == 0)
163164
System.err.println("Bad Win return");
164165
}
@@ -200,6 +201,58 @@ public static GeoStuff randomGeo() {
200201

201202
}
202203

204+
public static String makeWin2(Map bid, String xwin, Map r, double dcost) {
205+
String[] parts = xwin.split("http");
206+
String pre = xwin.substring(0,xwin.indexOf(":"));
207+
String lat = null;
208+
String lon = null;
209+
String uuid;
210+
String forward = "http:" + parts[1];
211+
parts = parts[1].split("/");
212+
213+
parts[8] = "" + dcost;
214+
215+
if (COUNT_MODE) {
216+
lat = "" + (double) r.get("lat");
217+
lon = "" + (double) r.get("lon");
218+
uuid = (String) r.get("uuid");
219+
} else {
220+
Map device = (Map) bid.get("device");
221+
if (device != null) {
222+
Map geo = (Map) device.get("geo");
223+
if (geo != null) {
224+
Double x = (Double) geo.get("lat");
225+
if (x != null) {
226+
lat = "" + x;
227+
x = (Double) geo.get("lon");
228+
lon = "" + x;
229+
}
230+
}
231+
}
232+
uuid = (String) bid.get("id");
233+
}
234+
235+
/**
236+
* Random cost
237+
*/
238+
Random rand = new Random();
239+
int Low = 760;
240+
int High = 1000;
241+
double Result = .001 * (rand.nextInt(High - Low) + Low);
242+
// cost = "" + Result * COST;
243+
244+
parts[9] = lat;
245+
parts[10] = lon;
246+
parts[13] = uuid;
247+
248+
249+
String str = pre + ":/";
250+
for (int i=2; i<parts.length;i++) {
251+
str = str + "/" + parts[i];
252+
}
253+
return str;
254+
255+
}
203256
public static String makeWin(Map bid, Map theBid, Map r, double dcost) {
204257
String str = winnah;
205258
String lat = "NA";

tools/testacctng

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
#
3+
# This runs the test bids/wins/clicks/pixels test program
4+
#
5+
java -Dlog4j.configuration="file:log4j.properties" -Xmx4096m -cp target/Bidder-0.0.1-SNAPSHOT-jar-with-dependencies.jar com.jacamars.dsp.rtb.tools.TestAccounting $1 $2 $3 $4

0 commit comments

Comments
 (0)