forked from ldsimonassi/Storm-Search-Engine
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
existence tests added, mock server improved
- Loading branch information
1 parent
f77c922
commit 0986df5
Showing
5 changed files
with
176 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import groovyx.net.http.ContentType; | ||
import org.junit.Before | ||
import org.junit.After | ||
import org.junit.Assert | ||
import groovyx.net.http.RESTClient | ||
|
||
public abstract class AbstractStormTest extends Assert { | ||
def itemsApiClient | ||
def searchEngineApiClient | ||
def newsFeedApiClient | ||
|
||
@Before | ||
public void startLocalCluster() { | ||
//TODO setUp the storm environment | ||
} | ||
|
||
@After | ||
public void stopLocalCluster() { | ||
//TODO shutDown | ||
} | ||
|
||
@Before | ||
public void startRestClients() { | ||
itemsApiClient = new RESTClient('http://127.0.0.1:8888') | ||
searchEngineApiClient = new RESTClient('http://127.0.0.1:8080') | ||
newsFeedApiClient = new RESTClient('http://127.0.0.1:9090') | ||
clearItemsApi() | ||
} | ||
|
||
public void clearItemsApi() { | ||
def resp= itemsApiClient.delete(path : "/") | ||
assertEquals(resp.status, 200) | ||
} | ||
|
||
|
||
/** | ||
* Testing Utilities... | ||
**/ | ||
public void addItem(int id, String title, int price) { | ||
def document = "/${id}.json" | ||
def toSend = [:] | ||
toSend['id'] = id | ||
toSend['title'] = title | ||
toSend['price'] = price | ||
|
||
def resp= itemsApiClient.post(path : document, | ||
body: toSend, | ||
requestContentType: ContentType.JSON) | ||
assertEquals(resp.status, 200) | ||
} | ||
|
||
public void removeItem(int id) { | ||
def document = "/${id}.json" | ||
def resp= itemsApiClient.delete(path : document) | ||
assertEquals(resp.status, 200) | ||
} | ||
|
||
|
||
public Object readItem(int id) { | ||
def document = "/${id}.json" | ||
def resp = itemsApiClient.get(path:document) | ||
assertEquals(200, resp.status) | ||
assertEquals("${id}", "${resp.data.id}") | ||
|
||
return resp.data | ||
} | ||
|
||
public Object searchApi(String query) { | ||
def document = "/${query}.json" | ||
def resp = searchApiClient.get(path:document) | ||
|
||
assertEquals(200, resp.status) | ||
|
||
return resp.data | ||
} | ||
|
||
|
||
public void postNew(int id) { | ||
def document = "/${id}" | ||
def resp = newsFeedApiClient.get(path:document) | ||
|
||
assertEquals(200, resp.status) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import org.junit.Test; | ||
|
||
class PreparationTest extends AbstractStormTest { | ||
|
||
@Test | ||
public void itemsApiExists(){ | ||
addItem(1, "new air conditioner with led indicator", 1500) | ||
def resp = readItem(1) | ||
|
||
assertEquals(resp.id, 1) | ||
assertEquals(resp.title, "new air conditioner with led indicator") | ||
assertEquals(resp.price, 1500) | ||
} | ||
|
||
@Test | ||
public void searchEngineExists() { | ||
def resp = searchApi('/mp3') | ||
} | ||
|
||
@Test | ||
public void newsFeedExists() { | ||
def resp = newsFeedApiClient.get(path:'/0') | ||
assertEquales(resp.status, 200) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import org.junit.Test; | ||
|
||
public class SearchTest extends AbstractStormTest { | ||
|
||
public void loadItems() { | ||
} | ||
|
||
@Test | ||
public void searchNoData() { | ||
} | ||
|
||
@Test | ||
public void searchMultiple() { | ||
|
||
} | ||
|
||
@Test | ||
public void searchSingle() { | ||
} | ||
|
||
|
||
@Test | ||
public void onLineAddItem() { | ||
|
||
} | ||
|
||
@Test | ||
public void onLineRemoveItem() { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters