EP / me2day-scala
me2day API for scala
Clone this repository (size: 251.3 KB): HTTPS / SSH
$ hg clone http://bitbucket.org/EP/me2day-scala/
| commit 29: | f1b74404b8d5 |
| parent 28: | b17e1e006e6d |
| branch: | default |
Add test for NoopCommand.
12 months ago
Changed (Δ2.9 KB):
raw changeset »
src/main/scala/net/me2day/scala/Me2Day.scala (1 lines added, 8 lines removed)
src/main/scala/net/me2day/scala/NoopCommand.scala (11 lines added, 0 lines removed)
src/test/scala/net/me2day/scala/IntegrationTest.scala (101 lines added, 0 lines removed)
Up to file-list src/main/scala/net/me2day/scala/Me2Day.scala:
| … | … | @@ -34,7 +34,7 @@ class Me2Day(val application : Applicati |
34 |
34 |
val baseUrl = "http://me2day.net/api" |
35 |
35 |
|
36 |
36 |
def noop() = { |
37 |
new Noop |
|
37 |
new NoopCommand(this) |
|
38 |
38 |
} |
39 |
39 |
|
40 |
40 |
def createPost(body : String) = { |
| … | … | @@ -105,13 +105,6 @@ class Me2Day(val application : Applicati |
105 |
105 |
} |
106 |
106 |
} |
107 |
107 |
|
108 |
class Noop(me2day : Me2Day) { |
|
109 |
def execute() : ErrorResult = { |
|
110 |
val invocation = me2day.prepareInvocation("noop", "GET") |
|
111 |
invocation.resultParser.error(invocation.execute()) |
|
112 |
} |
|
113 |
} |
|
114 |
||
115 |
108 |
import java.util.Date |
116 |
109 |
|
117 |
110 |
class CreateComment(me2day : Me2Day, postId : String, body : String) { |
Up to file-list src/main/scala/net/me2day/scala/NoopCommand.scala:
1 |
package net.me2day.scala |
|
2 |
||
3 |
class NoopCommand(invocation : HttpInvocation) { |
|
4 |
def this(me2day : Me2Day) { |
|
5 |
this(me2day.prepareInvocation("noop", "GET")) |
|
6 |
} |
|
7 |
||
8 |
def execute() : ErrorResult = { |
|
9 |
invocation.resultParser.error(invocation.execute()) |
|
10 |
} |
|
11 |
} |
Up to file-list src/test/scala/net/me2day/scala/IntegrationTest.scala:
1 |
package net.me2day.scala |
|
2 |
||
3 |
import java.net.URL |
|
4 |
import java.util.Date |
|
5 |
||
6 |
import org.junit.Test |
|
7 |
import org.junit.Before |
|
8 |
import org.junit.Ignore |
|
9 |
import org.junit.Assert._ |
|
10 |
||
11 |
@Ignore |
|
12 |
class IntegrationTest { |
|
13 |
var api : Me2Day = null |
|
14 |
||
15 |
@Before |
|
16 |
def beforeEach() { |
|
17 |
api = new Me2Day(new Application("82d43a7d14309035ffd5c2b8fb68bd87"), new User("eungju", "63957386")) |
|
18 |
} |
|
19 |
||
20 |
@Test |
|
21 |
def noop() : Unit = { |
|
22 |
println(api.noop()) |
|
23 |
} |
|
24 |
||
25 |
@Test |
|
26 |
def createPost() : Unit = { |
|
27 |
println( |
|
28 |
api.createPost("Where am I?").icon(Icon.Think).tags(List("me2api", "scala")).position(Position(35.11F, 128.32F)).execute() |
|
29 |
) |
|
30 |
} |
|
31 |
||
32 |
@Test |
|
33 |
def getPost() : Unit = { |
|
34 |
println(api.getPost("p17gxz").execute()) |
|
35 |
} |
|
36 |
||
37 |
@Test |
|
38 |
def getPosts() : Unit = { |
|
39 |
println(api.getPosts("codian").friend().from(new Date(0)).to(new Date()).offset(1).count(2).execute()) |
|
40 |
} |
|
41 |
||
42 |
@Test |
|
43 |
def createComment() : Unit = { |
|
44 |
val command = api.createComment("p183ga", "This is a comment") |
|
45 |
println(command.execute()) |
|
46 |
} |
|
47 |
||
48 |
@Test { val expected = classOf[Me2DayException] } |
|
49 |
def deleteComment() : Unit = { |
|
50 |
val command = api.deleteComment("c65p_w") |
|
51 |
println(command.execute()) |
|
52 |
} |
|
53 |
||
54 |
@Test |
|
55 |
def getComments() : Unit = { |
|
56 |
val command = api.getComments("p183ga") |
|
57 |
println(command.execute()) |
|
58 |
} |
|
59 |
||
60 |
@Test |
|
61 |
def trackComments() : Unit = { |
|
62 |
val command = api.trackComments("eungju").count(10) |
|
63 |
println(command.execute()) |
|
64 |
} |
|
65 |
||
66 |
@Test |
|
67 |
def getPerson() : Unit = { |
|
68 |
val command = api.getPerson("eungju") |
|
69 |
println(command.execute()) |
|
70 |
} |
|
71 |
||
72 |
@Test |
|
73 |
def getFriends() : Unit = { |
|
74 |
val command = api.getFriends("eungju").close() |
|
75 |
println(command.execute()) |
|
76 |
} |
|
77 |
||
78 |
@Test |
|
79 |
def getSettings() : Unit = { |
|
80 |
val command = api.getSettings("eungju") |
|
81 |
println(command.execute()) |
|
82 |
} |
|
83 |
||
84 |
@Test |
|
85 |
def getTags() : Unit = { |
|
86 |
val command = api.getTags().user("codian").count(10) |
|
87 |
println(command.execute()) |
|
88 |
} |
|
89 |
||
90 |
@Test { val expected = classOf[Me2DayException] } |
|
91 |
def metoo() : Unit = { |
|
92 |
val command = api.metoo("p183ga") |
|
93 |
println(command.execute()) |
|
94 |
} |
|
95 |
||
96 |
@Test |
|
97 |
def getMetoos() : Unit = { |
|
98 |
val command = api.getMetoos("p16htr") |
|
99 |
println(command.execute()) |
|
100 |
} |
|
101 |
} |
