use of org.javarosa.core.reference.Reference in project javarosa by opendatakit.
the class QuestionDefTest method testReferences.
@Test
public void testReferences() {
QuestionDef q = fpi.getFirstQuestionDef();
FormEntryPrompt fep = fpi.getFormEntryModel().getQuestionPrompt();
Localizer l = fpi.getFormDef().getLocalizer();
l.setDefaultLocale(l.getAvailableLocales()[0]);
l.setLocale(l.getAvailableLocales()[0]);
String audioURI = fep.getAudioText();
String ref;
ReferenceManager.instance().addReferenceFactory(new ResourceReferenceFactory());
ReferenceManager.instance().addRootTranslator(new RootTranslator("jr://audio/", "jr://resource/"));
try {
Reference r = ReferenceManager.instance().DeriveReference(audioURI);
ref = r.getURI();
if (!ref.equals("jr://resource/hah.mp3")) {
fail("Root translation failed.");
}
} catch (InvalidReferenceException ire) {
fail("There was an Invalid Reference Exception:" + ire.getMessage());
ire.printStackTrace();
}
ReferenceManager.instance().addRootTranslator(new RootTranslator("jr://images/", "jr://resource/"));
q = fpi.getNextQuestion();
fep = fpi.getFormEntryModel().getQuestionPrompt();
String imURI = fep.getImageText();
try {
Reference r = ReferenceManager.instance().DeriveReference(imURI);
ref = r.getURI();
if (!ref.equals("jr://resource/four.gif")) {
fail("Root translation failed.");
}
} catch (InvalidReferenceException ire) {
fail("There was an Invalid Reference Exception:" + ire.getMessage());
ire.printStackTrace();
}
}
use of org.javarosa.core.reference.Reference in project collect by opendatakit.
the class ChoicesRecyclerViewTest method setUpReferenceManager.
private void setUpReferenceManager() throws InvalidReferenceException {
referenceManager = mock(ReferenceManager.class);
Reference reference = mock(Reference.class);
when(reference.getLocalURI()).thenReturn("");
when(referenceManager.deriveReference(any())).thenReturn(reference);
}
use of org.javarosa.core.reference.Reference in project collect by opendatakit.
the class CollectHelpers method createFakeReference.
private static String createFakeReference(ReferenceManager referenceManager, String referenceURI, String localURI) throws InvalidReferenceException {
Reference reference = mock(Reference.class);
when(reference.getLocalURI()).thenReturn(localURI);
when(referenceManager.deriveReference(referenceURI)).thenReturn(reference);
return localURI;
}
Aggregations