Skip to content

Commit

Permalink
Whitespace only
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjmiller committed Dec 30, 2015
1 parent 9c8ba97 commit 016ecd4
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 68 deletions.
18 changes: 10 additions & 8 deletions src/main/java/com/rusticisoftware/tincan/LanguageMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private class LanguageMapIterator implements Iterator<Map.Entry<String, String>>
public LanguageMapIterator() {
iterator = _map.entrySet().iterator();
}

@Override
public boolean hasNext() {
return iterator.hasNext();
Expand All @@ -54,7 +55,8 @@ public Entry<String, String> next() {
@Override
public void remove() throws UnsupportedOperationException {
throw new UnsupportedOperationException(
"LanguageMap iterator does not implement the remove method");
"LanguageMap iterator does not implement the remove method"
);
}
}
public LanguageMap(JsonNode jsonNode) {
Expand All @@ -81,7 +83,7 @@ public ObjectNode toJSONNode(TCAPIVersion version) {
public String put(String key, String val) {
return this._map.put(key, val);
}

public String put(Map.Entry<String, String> entry) {
return this.put(entry.getKey(), entry.getValue());
}
Expand Down Expand Up @@ -110,13 +112,13 @@ public Map.Entry<String, String> findFirstValue(String value) {
}
return retVal;
}

public void populateWithAvailableLanguages(List<String> list) {
Iterator<Map.Entry<String, String>> it = this.iterator();
while (it.hasNext()) {
Map.Entry<String, String> n = it.next();
list.add(n.getKey());
}
Iterator<Map.Entry<String, String>> it = this.iterator();
while (it.hasNext()) {
Map.Entry<String, String> n = it.next();
list.add(n.getKey());
}
}

@Override
Expand Down
40 changes: 20 additions & 20 deletions src/main/java/com/rusticisoftware/tincan/RemoteLRS.java
Original file line number Diff line number Diff line change
Expand Up @@ -698,24 +698,24 @@ public LRSResponse clearState(Activity activity, Agent agent, UUID registration)

@Override
public ActivityProfileLRSResponse retrieveActivity(Activity activity) {
HashMap<String, String> queryParams = new HashMap<String, String>();
queryParams.put("activityId", activity.getId().toString());
ActivityProfileDocument profileDocument = new ActivityProfileDocument();
profileDocument.setActivity(activity);
profileDocument.setId(null);
LRSResponse lrsResp = getDocument("activities", queryParams, profileDocument);
HashMap<String, String> queryParams = new HashMap<String, String>();
queryParams.put("activityId", activity.getId().toString());
ActivityProfileDocument profileDocument = new ActivityProfileDocument();
profileDocument.setActivity(activity);
profileDocument.setId(null);

LRSResponse lrsResp = getDocument("activities", queryParams, profileDocument);

ActivityProfileLRSResponse lrsResponse = new ActivityProfileLRSResponse(lrsResp.getRequest(), lrsResp.getResponse());
lrsResponse.setSuccess(lrsResp.getSuccess());

if (lrsResponse.getResponse().getStatus() == 200) {
lrsResponse.setContent(profileDocument);
}

return lrsResponse;
return lrsResponse;
}

@Override
public ProfileKeysLRSResponse retrieveActivityProfileIds(Activity activity) {
HashMap<String, String> queryParams = new HashMap<String, String>();
Expand Down Expand Up @@ -777,24 +777,24 @@ public LRSResponse deleteActivityProfile(ActivityProfileDocument profile) {

@Override
public AgentProfileLRSResponse retrievePerson(Agent agent) {
HashMap<String, String> queryParams = new HashMap<String, String>();
queryParams.put("agent", agent.toJSON(TCAPIVersion.V100));
AgentProfileDocument profileDocument = new AgentProfileDocument();
profileDocument.setAgent(agent);
profileDocument.setId(null);
LRSResponse lrsResp = getDocument("agents", queryParams, profileDocument);
HashMap<String, String> queryParams = new HashMap<String, String>();
queryParams.put("agent", agent.toJSON(TCAPIVersion.V100));
AgentProfileDocument profileDocument = new AgentProfileDocument();
profileDocument.setAgent(agent);
profileDocument.setId(null);

LRSResponse lrsResp = getDocument("agents", queryParams, profileDocument);

AgentProfileLRSResponse lrsResponse = new AgentProfileLRSResponse(lrsResp.getRequest(), lrsResp.getResponse());
lrsResponse.setSuccess(lrsResp.getSuccess());

if (lrsResponse.getResponse().getStatus() == 200) {
lrsResponse.setContent(profileDocument);
}

return lrsResponse;
return lrsResponse;
}

@Override
public ProfileKeysLRSResponse retrieveAgentProfileIds(Agent agent) {
HashMap<String, String> queryParams = new HashMap<String, String>();
Expand Down
7 changes: 3 additions & 4 deletions src/test/java/com/rusticisoftware/tincan/LanguageMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Description
*/
public class LanguageMapTest {

@Test
public void serializeDeserialize() throws Exception {
LanguageMap lm = new LanguageMap();
Expand All @@ -53,7 +53,6 @@ public void fillAndIterate() {
}

String lmContent = lm.toJSON();

String lmCopyContent = lmCopy.toJSON();

assertEquals(lmContent, lmCopyContent);
Expand All @@ -74,8 +73,8 @@ public void fillAndIterate() {
assertEquals(arrayOfLangs.size(), 3);
assertEquals(linkedListOfLangs.size(), 3);
assertEquals(vectorOfLangs.size(), 3);
for(String s : linkedListOfLangs) {
assertTrue(lm.containsKey(s));
for (String s : linkedListOfLangs) {
assertTrue(lm.containsKey(s));
}
}
}
72 changes: 36 additions & 36 deletions src/test/java/com/rusticisoftware/tincan/RemoteLRSTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -525,26 +525,26 @@ public void testClearState() throws Exception {
@Test
public void testRetrieveActivity() throws Exception {
ActivityProfileLRSResponse lrsResponse = lrs.retrieveActivity(activity);
Assert.assertTrue(lrsResponse.getSuccess());

ActivityProfileDocument returnedDoc = lrsResponse.getContent();
Assert.assertNull(returnedDoc.getId()); // Retrieving the full Activity does not return a profile ID
Activity returnedActivity = returnedDoc.getActivity();
Assert.assertTrue(activity.getId().toString().equals(returnedActivity.getId().toString()));
// Test for non-existent activity
Activity noActivity = new Activity();
noActivity.setId("https://brindlewaye.com/xAPITerms/Activity/NeverGonnaHappen/");
Assert.assertTrue(lrsResponse.getSuccess());

ActivityProfileDocument returnedDoc = lrsResponse.getContent();
Assert.assertNull(returnedDoc.getId()); // Retrieving the full Activity does not return a profile ID
Activity returnedActivity = returnedDoc.getActivity();
Assert.assertTrue(activity.getId().toString().equals(returnedActivity.getId().toString()));

// Test for non-existent activity
Activity noActivity = new Activity();
noActivity.setId("https://brindlewaye.com/xAPITerms/Activity/NeverGonnaHappen/");

ActivityProfileLRSResponse lrsResponse2 = lrs.retrieveActivity(noActivity);
// Report success even though response status was 404
Assert.assertTrue(lrsResponse2.getSuccess());
Assert.assertTrue(lrsResponse2.getResponse().getStatus() == 404);
Assert.assertTrue(lrsResponse2.getSuccess());
Assert.assertTrue(lrsResponse2.getResponse().getStatus() == 404);

ActivityProfileDocument returnedDoc2 = lrsResponse2.getContent();
Assert.assertNull(returnedDoc2);
ActivityProfileDocument returnedDoc2 = lrsResponse2.getContent();
Assert.assertNull(returnedDoc2);
}

@Test
public void testRetrieveActivityProfileIds() throws Exception {
ProfileKeysLRSResponse lrsRes = lrs.retrieveActivityProfileIds(activity);
Expand Down Expand Up @@ -697,27 +697,27 @@ public void testDeleteActivityProfile() throws Exception {
@Test
public void testRetrievePerson() throws Exception {
AgentProfileLRSResponse lrsResponse = lrs.retrievePerson(agent);
Assert.assertTrue(lrsResponse.getSuccess());

AgentProfileDocument returnedDoc = lrsResponse.getContent();
Assert.assertNull(returnedDoc.getId()); // Retrieving the full Agent does not return a profile ID
Agent returnedAgent = returnedDoc.getAgent();
Assert.assertTrue(agent.getName().equals(returnedAgent.getName()));
// Test for non-existent agent
Agent noAgent = new Agent();
noAgent.setMbox("mailto:[email protected]");
noAgent.setName("No One");
Assert.assertTrue(lrsResponse.getSuccess());

AgentProfileDocument returnedDoc = lrsResponse.getContent();
Assert.assertNull(returnedDoc.getId()); // Retrieving the full Agent does not return a profile ID
Agent returnedAgent = returnedDoc.getAgent();
Assert.assertTrue(agent.getName().equals(returnedAgent.getName()));

// Test for non-existent agent
Agent noAgent = new Agent();
noAgent.setMbox("mailto:[email protected]");
noAgent.setName("No One");

AgentProfileLRSResponse lrsResponse2 = lrs.retrievePerson(noAgent);
Assert.assertTrue(lrsResponse2.getSuccess());
Assert.assertTrue(lrsResponse2.getResponse().getStatus() == 200);
Agent returnedAgent2 = lrsResponse2.getContent().getAgent();
// The spec says that this call will return an object built from the information provided in the parameter Agent if it finds nothing matching at the endpoint
Assert.assertTrue(returnedAgent2.equals(noAgent));
}
Assert.assertTrue(lrsResponse2.getSuccess());
Assert.assertTrue(lrsResponse2.getResponse().getStatus() == 200);

Agent returnedAgent2 = lrsResponse2.getContent().getAgent();
// The spec says that this call will return an object built from the information provided in the parameter Agent if it finds nothing matching at the endpoint
Assert.assertTrue(returnedAgent2.equals(noAgent));
}

@Test
public void testRetrieveAgentProfileIds() throws Exception {
ProfileKeysLRSResponse lrsRes = lrs.retrieveAgentProfileIds(agent);
Expand Down

0 comments on commit 016ecd4

Please sign in to comment.