use string name for JacksonInject to make it easy to read
java
This commit is contained in:
parent
f86b65e12a
commit
9d026bbdbc
@ -134,7 +134,7 @@ public class IndexV1Updater extends RepoUpdater {
|
|||||||
throws IOException, UpdateException {
|
throws IOException, UpdateException {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||||
mapper.setInjectableValues(new InjectableValues.Std().addValue(long.class, repo.getId()));
|
mapper.setInjectableValues(new InjectableValues.Std().addValue("repoId", repo.getId()));
|
||||||
JsonFactory f = mapper.getFactory();
|
JsonFactory f = mapper.getFactory();
|
||||||
JsonParser parser = f.createParser(indexInputStream);
|
JsonParser parser = f.createParser(indexInputStream);
|
||||||
HashMap<String, Object> repoMap = null;
|
HashMap<String, Object> repoMap = null;
|
||||||
|
@ -56,8 +56,8 @@ public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public boolean compatible; // True if compatible with the device.
|
public boolean compatible; // True if compatible with the device.
|
||||||
|
|
||||||
@JacksonInject
|
@JacksonInject("repoId")
|
||||||
public long repoId; // ID of the repo it comes from
|
public long repoId; // the database ID of the repo it comes from
|
||||||
|
|
||||||
// these come directly from the index metadata
|
// these come directly from the index metadata
|
||||||
public String packageName;
|
public String packageName;
|
||||||
|
@ -98,7 +98,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
|||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private AppPrefs prefs;
|
private AppPrefs prefs;
|
||||||
|
|
||||||
@JacksonInject
|
@JacksonInject("repoId")
|
||||||
public long repoId;
|
public long repoId;
|
||||||
|
|
||||||
// the remaining properties are set directly from the index metadata
|
// the remaining properties are set directly from the index metadata
|
||||||
|
@ -163,6 +163,9 @@ public class Repo extends ValueObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the database ID to find this repo in the database
|
||||||
|
*/
|
||||||
public long getId() {
|
public long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,16 @@ import com.fasterxml.jackson.databind.InjectableValues;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.ObjectReader;
|
import com.fasterxml.jackson.databind.ObjectReader;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.fdroid.fdroid.*;
|
import org.fdroid.fdroid.BuildConfig;
|
||||||
import org.fdroid.fdroid.data.*;
|
import org.fdroid.fdroid.IndexV1Updater;
|
||||||
|
import org.fdroid.fdroid.Preferences;
|
||||||
|
import org.fdroid.fdroid.RepoUpdater;
|
||||||
|
import org.fdroid.fdroid.TestUtils;
|
||||||
|
import org.fdroid.fdroid.data.Apk;
|
||||||
|
import org.fdroid.fdroid.data.App;
|
||||||
|
import org.fdroid.fdroid.data.FDroidProviderTest;
|
||||||
|
import org.fdroid.fdroid.data.Repo;
|
||||||
|
import org.fdroid.fdroid.data.RepoPushRequest;
|
||||||
import org.fdroid.fdroid.mock.RepoDetails;
|
import org.fdroid.fdroid.mock.RepoDetails;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@ -22,7 +30,13 @@ import org.robolectric.annotation.Config;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
import java.util.jar.JarEntry;
|
import java.util.jar.JarEntry;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
|
|
||||||
@ -118,7 +132,7 @@ public class IndexV1UpdaterTest extends FDroidProviderTest {
|
|||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
// the app ignores all unknown fields when complete, do not ignore during dev to catch mistakes
|
// the app ignores all unknown fields when complete, do not ignore during dev to catch mistakes
|
||||||
mapper.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
mapper.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||||
mapper.setInjectableValues(new InjectableValues.Std().addValue(long.class, FAKE_REPO_ID));
|
mapper.setInjectableValues(new InjectableValues.Std().addValue("repoId", FAKE_REPO_ID));
|
||||||
JsonFactory f = mapper.getFactory();
|
JsonFactory f = mapper.getFactory();
|
||||||
JsonParser parser = f.createParser(TestUtils.copyResourceToTempFile("guardianproject_index-v1.json"));
|
JsonParser parser = f.createParser(TestUtils.copyResourceToTempFile("guardianproject_index-v1.json"));
|
||||||
|
|
||||||
@ -310,7 +324,7 @@ public class IndexV1UpdaterTest extends FDroidProviderTest {
|
|||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
// testing with unknown metadata in it
|
// testing with unknown metadata in it
|
||||||
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||||
mapper.setInjectableValues(new InjectableValues.Std().addValue(long.class, FAKE_REPO_ID));
|
mapper.setInjectableValues(new InjectableValues.Std().addValue("repoId", FAKE_REPO_ID));
|
||||||
JsonFactory f = mapper.getFactory();
|
JsonFactory f = mapper.getFactory();
|
||||||
JsonParser parser = f.createParser(TestUtils.copyResourceToTempFile("all_fields_index-v1.json"));
|
JsonParser parser = f.createParser(TestUtils.copyResourceToTempFile("all_fields_index-v1.json"));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user