@Test public void testConvertJcrValue() throws Exception { ValueFactory vf = ValueFactoryImpl.getInstance(); final String expectString = "hey I'm a string"; assertEquals("expect equal string", expectString, DefaultSlingSimulator.convertJcrValue(vf.createValue(expectString))); final Calendar expectDate = Calendar.getInstance(); assertEquals("expect equal date", expectDate, DefaultSlingSimulator.convertJcrValue(vf.createValue(expectDate))); final double expectDouble = 42.0D; assertEquals("expect equal double", expectDouble, (Double) DefaultSlingSimulator.convertJcrValue(vf.createValue(expectDouble)), 1.0D); final long expectLong = 404L; assertEquals("expect equal long", expectLong, DefaultSlingSimulator.convertJcrValue(vf.createValue(expectLong))); final Boolean expectBoolean = Boolean.TRUE; assertEquals("expect equal boolean", expectBoolean, DefaultSlingSimulator.convertJcrValue(vf.createValue(expectBoolean))); assertNull("expect null for name", DefaultSlingSimulator.convertJcrValue(vf.createValue("aName", PropertyType.NAME))); }
static @Nullable Object convertJcrValue(final @NotNull Value value) throws RepositoryException { switch (value.getType()) { case PropertyType.STRING: return value.getString(); case PropertyType.DATE: return value.getDate(); case PropertyType.DOUBLE: return value.getDouble(); case PropertyType.LONG: return value.getLong(); case PropertyType.BOOLEAN: return value.getBoolean(); } return null; }
DefaultSlingSimulator implements SlingSimulatorBackend, SlingSimulator { static @Nullable Object convertJcrValue(final @NotNull Value value) throws RepositoryException { switch (value.getType()) { case PropertyType.STRING: return value.getString(); case PropertyType.DATE: return value.getDate(); case PropertyType.DOUBLE: return value.getDouble(); case PropertyType.LONG: return value.getLong(); case PropertyType.BOOLEAN: return value.getBoolean(); } return null; } }
DefaultSlingSimulator implements SlingSimulatorBackend, SlingSimulator { static @Nullable Object convertJcrValue(final @NotNull Value value) throws RepositoryException { switch (value.getType()) { case PropertyType.STRING: return value.getString(); case PropertyType.DATE: return value.getDate(); case PropertyType.DOUBLE: return value.getDouble(); case PropertyType.LONG: return value.getLong(); case PropertyType.BOOLEAN: return value.getBoolean(); } return null; }  }
DefaultSlingSimulator implements SlingSimulatorBackend, SlingSimulator { static @Nullable Object convertJcrValue(final @NotNull Value value) throws RepositoryException { switch (value.getType()) { case PropertyType.STRING: return value.getString(); case PropertyType.DATE: return value.getDate(); case PropertyType.DOUBLE: return value.getDouble(); case PropertyType.LONG: return value.getLong(); case PropertyType.BOOLEAN: return value.getBoolean(); } return null; }  static SlingSimulatorBackend instance(); @Override void startedScan(); @Override void setSession(final Session session); @Override void setPackageManager(final JcrPackageManager packageManager); @Override void setErrorListener(final ErrorListener errorListener); @Override @Nullable SlingInstallable dequeueInstallable(); @SuppressWarnings("unchecked") @Override @NotNull Fun.ThrowingSupplier<ResourceType> open(@NotNull final SlingOpenable<ResourceType> installable); @NotNull JcrPackage openEmbeddedPackage(@NotNull final EmbeddedPackageInstallable installable); @Override @Nullable SlingInstallable addInstallableNode(final @NotNull PackageId parentPackageId,
                                                         final @NotNull Node node); }
DefaultSlingSimulator implements SlingSimulatorBackend, SlingSimulator { static @Nullable Object convertJcrValue(final @NotNull Value value) throws RepositoryException { switch (value.getType()) { case PropertyType.STRING: return value.getString(); case PropertyType.DATE: return value.getDate(); case PropertyType.DOUBLE: return value.getDouble(); case PropertyType.LONG: return value.getLong(); case PropertyType.BOOLEAN: return value.getBoolean(); } return null; }  static SlingSimulatorBackend instance(); @Override void startedScan(); @Override void setSession(final Session session); @Override void setPackageManager(final JcrPackageManager packageManager); @Override void setErrorListener(final ErrorListener errorListener); @Override @Nullable SlingInstallable dequeueInstallable(); @SuppressWarnings("unchecked") @Override @NotNull Fun.ThrowingSupplier<ResourceType> open(@NotNull final SlingOpenable<ResourceType> installable); @NotNull JcrPackage openEmbeddedPackage(@NotNull final EmbeddedPackageInstallable installable); @Override @Nullable SlingInstallable addInstallableNode(final @NotNull PackageId parentPackageId,
                                                         final @NotNull Node node);  }