InstanceUploaderUtils { public static boolean shouldFormBeDeleted(FormsRepository formsRepository, String jrFormId, String jrFormVersion, boolean isAutoDeleteAppSettingEnabled) { Form form = formsRepository.get(jrFormId, jrFormVersion); if (form == null) { return false; } return form.getAutoDelete() == null ? isAutoDeleteAppSettingEnabled : Boolean.valueOf(form.getAutoDelete()); } private  InstanceUploaderUtils(); static String getUploadResultMessage(InstancesRepository instancesRepository, Context context, Map<String, String> result); static boolean doesUrlRefersToGoogleSheetsFile(String url); static boolean shouldFormBeDeleted(FormsRepository formsRepository, String jrFormId, String jrFormVersion, boolean isAutoDeleteAppSettingEnabled); static final String DEFAULT_SUCCESSFUL_TEXT; static final String SPREADSHEET_UPLOADED_TO_GOOGLE_DRIVE; }
@Test public void shouldFormBeDeletedFunction_shouldReturnFalseIfAutoDeleteNotSpecifiedOnFormLevelAndDisabledInSettings() { InMemFormsRepository formsRepository = new InMemFormsRepository(); formsRepository.save(new Form.Builder() .id(1L) .jrFormId("1") .jrVersion("1") .build()); assertThat(InstanceUploaderUtils.shouldFormBeDeleted(formsRepository, "1", "1", false), is(false)); }
@Test public void shouldFormBeDeletedFunction_shouldReturnTrueIfAutoDeleteNotSpecifiedOnFormLevelButEnabledInSettings() { InMemFormsRepository formsRepository = new InMemFormsRepository(); formsRepository.save(new Form.Builder() .id(1L) .jrFormId("1") .jrVersion("1") .build()); assertThat(InstanceUploaderUtils.shouldFormBeDeleted(formsRepository, "1", "1", true), is(true)); }
@Test public void shouldFormBeDeletedFunction_shouldReturnFalseIfAutoDeleteSpecifiedAsFalseOnFormLevelButEnabledInSettings() { InMemFormsRepository formsRepository = new InMemFormsRepository(); formsRepository.save(new Form.Builder() .id(1L) .jrFormId("1") .jrVersion("1") .autoDelete("false") .build()); assertThat(InstanceUploaderUtils.shouldFormBeDeleted(formsRepository, "1", "1", true), is(false)); }
@Test public void shouldFormBeDeletedFunction_shouldReturnTrueIfAutoDeleteSpecifiedAsTrueOnFormLevelButDisabledInSettings() { InMemFormsRepository formsRepository = new InMemFormsRepository(); formsRepository.save(new Form.Builder() .id(1L) .jrFormId("1") .jrVersion("1") .autoDelete("true") .build()); assertThat(InstanceUploaderUtils.shouldFormBeDeleted(formsRepository, "1", "1", false), is(true)); }