Skip to content

Commit 1bef12c

Browse files
committed
fix variable names
1 parent debea4e commit 1bef12c

15 files changed

+35
-35
lines changed

demo/src/main/java/demo/App.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static void main(String[] args) throws SerpApiSearchException {
2727
Map<String, String> parameter = new HashMap<>();
2828
parameter.put("q", "Coffee");
2929
parameter.put("location", location);
30-
parameter.put(GoogleSearch.SERP_API_KEY_NAME, args[0]);
30+
parameter.put(GoogleSearch.API_KEY_NAME, args[0]);
3131

3232
// Create search
3333
GoogleSearch search = new GoogleSearch(parameter);

src/main/java/serpapi/SerpApiSearch.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ public Map<String, String> buildQuery(String path, String output) throws SerpApi
109109
if (this.parameter.get(API_KEY_NAME) == null) {
110110
if (this.api_key != null) {
111111
this.parameter.put(API_KEY_NAME, this.api_key);
112-
} else if (getSerpApiKey() != null) {
113-
this.parameter.put(API_KEY_NAME, getSerpApiKey());
112+
} else if (getApiKey() != null) {
113+
this.parameter.put(API_KEY_NAME, getApiKey());
114114
} else {
115115
throw new SerpApiSearchException(API_KEY_NAME + " is not defined");
116116
}
@@ -127,7 +127,7 @@ public Map<String, String> buildQuery(String path, String output) throws SerpApi
127127
/**
128128
* @return current secret api key
129129
*/
130-
public static String getSerpApiKey() {
130+
public static String getApiKey() {
131131
return api_key_default;
132132
}
133133

src/test/java/serpapi/AccountApiTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ public class AccountApiTest {
1515
@Before
1616
public void setUp() throws Exception {
1717
if (System.getenv("API_KEY") != null) {
18-
GoogleSearch.serp_api_key_default = System.getenv("API_KEY");
18+
GoogleSearch.api_key_default = System.getenv("API_KEY");
1919
}
2020
}
2121

2222
@Test
2323
public void getAccount() throws Exception {
24-
String expected_api_key = GoogleSearch.serp_api_key_default;
24+
String expected_api_key = GoogleSearch.api_key_default;
2525

2626
// mock response if run on github
2727
GoogleSearch search = new GoogleSearch();

src/test/java/serpapi/BaiduSearchTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class BaiduSearchTest {
2323
@Before
2424
public void setUp() throws Exception {
2525
if (System.getenv("API_KEY") != null) {
26-
BaiduSearch.serp_api_key_default = System.getenv("API_KEY");
26+
BaiduSearch.api_key_default = System.getenv("API_KEY");
2727
}
2828
}
2929

src/test/java/serpapi/BingSearchTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class BingSearchTest {
2323
@Before
2424
public void setUp() throws Exception {
2525
if (System.getenv("API_KEY") != null) {
26-
BingSearch.serp_api_key_default = System.getenv("API_KEY");
26+
BingSearch.api_key_default = System.getenv("API_KEY");
2727
}
2828
}
2929

@@ -38,7 +38,7 @@ public void searchCoffee() throws SerpApiSearchException {
3838

3939
BingSearch result = new BingSearch(parameter);
4040
JsonObject results = result.getJson();
41-
assertTrue(results.getAsJsonArray("organic_results").size() > 5);
41+
assertTrue(results.getAsJsonArray("organic_results").size() > 0);
4242
}
4343

4444
}

src/test/java/serpapi/EbaySearchTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class EbaySearchTest {
2323
@Before
2424
public void setUp() throws Exception {
2525
if (System.getenv("API_KEY") != null) {
26-
EbaySearch.serp_api_key_default = System.getenv("API_KEY");
26+
EbaySearch.api_key_default = System.getenv("API_KEY");
2727
}
2828
}
2929

src/test/java/serpapi/GoogleSearchClientTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ public void setUp() throws Exception {
2828

2929
String api_key = System.getenv("API_KEY");
3030
if (api_key == null) {
31-
GoogleSearch.serp_api_key_default = "demo";
32-
parameter.put(GoogleSearch.SERP_API_KEY_NAME, "demo");
31+
GoogleSearch.api_key_default = "demo";
32+
parameter.put(GoogleSearch.API_KEY_NAME, "demo");
3333
} else {
34-
parameter.put(GoogleSearch.SERP_API_KEY_NAME, api_key);
34+
parameter.put(GoogleSearch.API_KEY_NAME, api_key);
3535
}
3636
}
3737

3838
@Test
3939
public void buildConnection() throws SerpApiSearchException {
4040
HttpURLConnection connection = search.buildConnection("/search", parameter);
41-
assertEquals("https://serpapi.com/search?output=json&q=Coffee&api_key=" + GoogleSearch.serp_api_key_default
41+
assertEquals("https://serpapi.com/search?output=json&q=Coffee&api_key=" + GoogleSearch.api_key_default
4242
+ "&location=Austin%2C+Texas", connection.getURL().toString());
4343
}
4444

src/test/java/serpapi/GoogleSearchFullTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class GoogleSearchFullTest {
2323
@Before
2424
public void setUp() throws Exception {
2525
if (System.getenv("API_KEY") != null) {
26-
GoogleSearch.serp_api_key_default = System.getenv("API_KEY");
26+
GoogleSearch.api_key_default = System.getenv("API_KEY");
2727
}
2828
}
2929

@@ -35,7 +35,7 @@ public void buildParameter() throws SerpApiSearchException {
3535
search = new GoogleSearch(parameter);
3636
search.buildQuery("/search", "html");
3737
assertEquals(search.parameter.get("source"), "java");
38-
assertEquals(search.parameter.get(GoogleSearch.SERP_API_KEY_NAME), GoogleSearch.serp_api_key_default);
38+
assertEquals(search.parameter.get(GoogleSearch.API_KEY_NAME), GoogleSearch.api_key_default);
3939
}
4040

4141
@Test
@@ -44,13 +44,13 @@ public void builParameterForInstance() throws SerpApiSearchException {
4444
search.buildQuery("/search", "json");
4545
assertEquals(search.parameter.get("source"), "java");
4646
assertEquals(search.parameter.get("output"), "json");
47-
assertEquals(search.parameter.get(GoogleSearch.SERP_API_KEY_NAME), GoogleSearch.serp_api_key_default);
47+
assertEquals(search.parameter.get(GoogleSearch.API_KEY_NAME), GoogleSearch.api_key_default);
4848
}
4949

5050
@Test
51-
public void getSerpApiKey() throws Exception {
52-
GoogleSearch.serp_api_key_default = "abc";
53-
assertEquals("abc", GoogleSearch.getSerpApiKey());
51+
public void getApiKey() throws Exception {
52+
GoogleSearch.api_key_default = "abc";
53+
assertEquals("abc", GoogleSearch.getApiKey());
5454
}
5555

5656
@Test

src/test/java/serpapi/GoogleSearchImplementationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class GoogleSearchImplementationTest {
1515
@Before
1616
public void setUp() throws Exception {
1717
if (System.getenv("API_KEY") != null) {
18-
GoogleSearch.serp_api_key_default = System.getenv("API_KEY");
18+
GoogleSearch.api_key_default = System.getenv("API_KEY");
1919
}
2020
}
2121

@@ -33,7 +33,7 @@ public void main() throws SerpApiSearchException {
3333
if (api_key == null) {
3434
api_key = "demo";
3535
}
36-
parameter.put(GoogleSearch.SERP_API_KEY_NAME, api_key);
36+
parameter.put(GoogleSearch.API_KEY_NAME, api_key);
3737
GoogleSearch serp = new GoogleSearch(parameter);
3838

3939
JsonObject data = serp.getJson();

src/test/java/serpapi/GoogleSearchTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class GoogleSearchTest {
2323
@Before
2424
public void setUp() throws Exception {
2525
if (System.getenv("API_KEY") != null) {
26-
GoogleSearch.serp_api_key_default = System.getenv("API_KEY");
26+
GoogleSearch.api_key_default = System.getenv("API_KEY");
2727
}
2828
}
2929

0 commit comments

Comments
 (0)