-
-
Notifications
You must be signed in to change notification settings - Fork 289
Closed
Description
I use your client library to communicate with spotify api. It works well but I've caught exception with requests that contains path variables like v1/albums/{id} in request path. Library doesn't replace path variable key correctly.
The project is for android. It configured with java 8.
I've added:
- code to test
- line with where exception occures
- stacktrace
- part of gradle config
Line that fires exception:
240: builtPath = builtPath.replaceAll("\\{" + nameValuePair.getName() + "}", nameValuePair.getValue());
Code to reproduce:
import com.wrapper.spotify.SpotifyApi;
import com.wrapper.spotify.exceptions.SpotifyWebApiException;
import com.wrapper.spotify.model_objects.specification.Album;
import com.wrapper.spotify.model_objects.specification.Artist;
import org.apache.hc.core5.http.ParseException;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import dagger.hilt.android.testing.HiltAndroidTest;
@HiltAndroidTest
public class FetchByIdTest extends BaseSpotifyTest {
@Test
public void testAlbumById() throws ParseException, SpotifyWebApiException, IOException {
//https://developer.spotify.com/console/get-album/?id=1IVuDXU95irZD6n7veVlUs
SpotifyApi api = dataManager.getApi();
String albumId = "1IVuDXU95irZD6n7veVlUs";
Album album = api.getAlbum(albumId).build().execute();
Assert.assertNotNull(album);
}
@Test
public void testArtistById() throws ParseException, SpotifyWebApiException, IOException {
//https://developer.spotify.com/console/get-artist/?id=0LyfQWJT6nXafLPZqxe9Of
SpotifyApi api = dataManager.getApi();
String artistId = "0LyfQWJT6nXafLPZqxe9Of";
Artist artist = api.getArtist(artistId).build().execute();
Assert.assertNotNull(artist);
}
}
Error Stack Trace:
The stacktrace is the same for both tests
2021-02-16 15:35:19.797 E/TestRunner: java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 5
\{id}
^
at java.util.regex.Pattern.compileImpl(Native Method)
at java.util.regex.Pattern.compile(Pattern.java:1344)
at java.util.regex.Pattern.<init>(Pattern.java:1328)
at java.util.regex.Pattern.compile(Pattern.java:950)
at java.lang.String.replaceAll(String.java:2286)
at com.wrapper.spotify.requests.AbstractRequest$Builder.setPath(AbstractRequest.java:240)
at com.wrapper.spotify.requests.data.albums.GetAlbumRequest$Builder.build(GetAlbumRequest.java:90)
at com.dts.conrad.automotive.spotify.FetchByIdTest.testAlbumById(FetchByIdTest.java:25)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at androidx.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:80)
at dagger.hilt.android.internal.testing.MarkThatRulesRanRule$1.evaluate(MarkThatRulesRanRule.java:92)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:395)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2152)
Gradle config:
android {
//...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
//...
}
Metadata
Metadata
Assignees
Labels
No labels