File tree Expand file tree Collapse file tree 4 files changed +59
-5
lines changed
main/java/com/spotify/requests
test/java/com/spotify/requests/tracks Expand file tree Collapse file tree 4 files changed +59
-5
lines changed Original file line number Diff line number Diff line change 66
77
88 <groupId >com.spotstat</groupId >
9- <artifactId >spotstat </artifactId >
10- <version >1.0-SNAPSHOT </version >
9+ <artifactId >S4J </artifactId >
10+ <version >1.1a </version >
1111
1212 <properties >
1313 <maven .compiler.source>17</maven .compiler.source>
1818
1919 <dependency >
2020 <groupId >org.junit.jupiter</groupId >
21- <artifactId >junit-jupiter-api </artifactId >
21+ <artifactId >junit-jupiter</artifactId >
2222 <version >5.8.2</version >
2323 <scope >test</scope >
2424 </dependency >
2525
2626 </dependencies >
2727
28+ <build >
29+ <plugins >
30+ <plugin >
31+ <groupId >org.apache.maven.plugins</groupId >
32+ <artifactId >maven-surefire-plugin</artifactId >
33+ <version >2.22.2</version >
34+ <configuration >
35+ <excludedGroups >SlowNetworkTest</excludedGroups >
36+ </configuration >
37+ </plugin >
38+ </plugins >
39+ </build >
40+
2841
2942</project >
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ public String buildRequestUrl() {
108108
109109 url = spotifyRequest .value ();
110110 StringBuilder sb = new StringBuilder (url );
111- // if (!url.endsWith("/")) sb.append("/");
111+ if (!url .endsWith ("/" )) sb .append ("/" );
112112
113113 List <Field > spotifySubRequestFields = new ArrayList <>();
114114 List <Field > spotifyFieldRequestFields = new ArrayList <>();
@@ -140,7 +140,10 @@ public String buildRequestUrl() {
140140 // Fields annotated with SpotifyRequestField
141141 for (Field field : spotifyFieldRequestFields ) {
142142 field .setAccessible (true );
143- if (!sb .toString ().endsWith ("&" ) && !sb .toString ().endsWith ("/" )) sb .append ("?" );
143+ if (sb .toString ().endsWith ("/" )) {
144+ sb = new StringBuilder (sb .substring (0 , sb .length () - 1 ));
145+ sb .append ("?" );
146+ }
144147
145148 Object o = field .get (this );
146149 Class <?> type = field .getType ();
Original file line number Diff line number Diff line change 44import com .spotify .SpotifyClientBuilderTester ;
55import com .spotify .requests .RequestResponse ;
66import com .spotify .requests .util .Market ;
7+ import org .junit .jupiter .api .Tag ;
78import org .junit .jupiter .api .Test ;
89
910import static org .junit .jupiter .api .Assertions .assertEquals ;
@@ -27,6 +28,7 @@ public void severalTrackGetUrlBuildTest() {
2728
2829
2930 @ Test
31+ @ Tag ("SlowNetworkTest" )
3032 public void severalTrackGetExecuteTest () {
3133 String [] songs = new String []{"1ljziaoMnRH95aPeOSGAtr" , "2fOYcnUo9iPTOqIlSg26MY" };
3234 SeveralTracksGet tracksGet = new SeveralTracksGet (songs );
Original file line number Diff line number Diff line change 1+ package com .spotify .requests .tracks ;
2+
3+ import com .spotify .SpotifyClient ;
4+ import com .spotify .SpotifyClientBuilderTester ;
5+ import com .spotify .requests .RequestResponse ;
6+ import org .junit .jupiter .api .Tag ;
7+ import org .junit .jupiter .api .Test ;
8+
9+ import static org .junit .jupiter .api .Assertions .assertEquals ;
10+
11+ class TrackGetTest {
12+
13+
14+ @ Test
15+ public void trackGetUrlBuildTest () {
16+ TrackGet trackGet = new TrackGet ("id1" );
17+
18+
19+ String url = trackGet .buildRequestUrl ();
20+
21+
22+ assertEquals ("tracks/id1" , url );
23+ }
24+
25+ @ Test
26+ @ Tag ("SlowNetworkTest" )
27+ public void trackGetExecuteTest () {
28+ String id = "2fOYcnUo9iPTOqIlSg26MY" ;
29+ TrackGet trackGet = new TrackGet (id );
30+ SpotifyClient scbt = new SpotifyClientBuilderTester ().getBuiltClient ();
31+ RequestResponse response = scbt .executeRequest (trackGet );
32+
33+ assertEquals (200 , response .getCode ());
34+ }
35+
36+ }
You can’t perform that action at this time.
0 commit comments