public static List<String> flattenPropeties(final Object target, final Class<?> clazz, final String... excludedProperties) { return flattenProperties(target, clazz, ImmutableSet.copyOf(excludedProperties)); }
protected String backupSnapshotToS3(final Connection connection, final S3TO s3, final String srUuid, final String folder, final String snapshotUuid, final Boolean iSCSIFlag, final int wait) { final String filename = iSCSIFlag ? "VHD-" + snapshotUuid : snapshotUuid + ".vhd"; final String dir = (iSCSIFlag ? "/dev/VG_XenStorage-" : "/var/run/sr-mount/") + srUuid; final String key = folder + "/" + filename; // String.format("/snapshots/%1$s", snapshotUuid); try { final List<String> parameters = newArrayList(flattenProperties(s3, ClientOptions.class)); // https workaround for Introspector bug that does not // recognize Boolean accessor methods ... parameters.addAll(Arrays.asList("operation", "put", "filename", dir + "/" + filename, "iSCSIFlag", iSCSIFlag.toString(), "bucket", s3.getBucketName(), "key", key, "https", s3.isHttps() != null ? s3.isHttps().toString() : "null", "maxSingleUploadSizeInBytes", String.valueOf(s3.getMaxSingleUploadSizeInBytes()))); final String result = hypervisorResource.callHostPluginAsync(connection, "s3xenserver", "s3", wait, parameters.toArray(new String[parameters.size()])); if (result != null && result.equals("true")) { return key; } return null; } catch (final Exception e) { s_logger.error(String.format("S3 upload failed of snapshot %1$s due to %2$s.", snapshotUuid, e.toString()), e); } return null; }
@Test public void testFlattenPropertiesNullTarget() throws Exception { assertEquals(emptyList(), flattenProperties(null, Bean.class)); }
@Test public void testFlattenNonNullProperties() throws Exception { final List<String> expectedResult = newArrayList("booleanProperty", TRUE.toString(), "intProperty", "1", "stringProperty", "foo"); final Bean bean = new Bean(1, true, "foo"); assertEquals(expectedResult, flattenProperties(bean, Bean.class)); }
@Test public void testFlattenNullProperties() throws Exception { final List<String> expectedResult = newArrayList("booleanProperty", TRUE.toString(), "intProperty", "1", "stringProperty", "null"); final Bean bean = new Bean(1, true, null); assertEquals(expectedResult, flattenProperties(bean, Bean.class)); }
public static List<String> flattenPropeties(final Object target, final Class<?> clazz, final String... excludedProperties) { return flattenProperties(target, clazz, ImmutableSet.copyOf(excludedProperties)); }
@Test public void testFlattenNullProperties() throws Exception { final List<String> expectedResult = newArrayList("booleanProperty", TRUE.toString(), "intProperty", "1", "stringProperty", "null"); final Bean bean = new Bean(1, true, null); assertEquals(expectedResult, flattenProperties(bean, Bean.class)); }
@Test public void testFlattenPropertiesNullTarget() throws Exception { assertEquals(emptyList(), flattenProperties(null, Bean.class)); }
@Test public void testFlattenNonNullProperties() throws Exception { final List<String> expectedResult = newArrayList("booleanProperty", TRUE.toString(), "intProperty", "1", "stringProperty", "foo"); final Bean bean = new Bean(1, true, "foo"); assertEquals(expectedResult, flattenProperties(bean, Bean.class)); }