use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.
the class DhisConvenienceTest method createCategoryCombo.
/**
* @param categoryComboUniqueIdentifier A unique character to identify the
* category option combo.
* @param categories the categories category options.
* @return CategoryOptionCombo
*/
public static CategoryCombo createCategoryCombo(char categoryComboUniqueIdentifier, Category... categories) {
CategoryCombo categoryCombo = new CategoryCombo("CategoryCombo" + categoryComboUniqueIdentifier, DataDimensionType.DISAGGREGATION);
categoryCombo.setAutoFields();
for (Category category : categories) {
categoryCombo.getCategories().add(category);
}
return categoryCombo;
}
use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.
the class SharingControllerTest method systemDefaultMetadataNoAccess.
@Test
void systemDefaultMetadataNoAccess() {
final Category category = new Category();
category.setName(Category.DEFAULT_NAME + "x");
doReturn(Category.class).when(aclService).classForType(eq("category"));
when(aclService.isClassShareable(eq(Category.class))).thenReturn(true);
when(manager.getNoAcl(eq(Category.class), eq("kkSjhdhks"))).thenReturn(category);
assertThrows(AccessDeniedException.class, () -> sharingController.postSharing("category", "kkSjhdhks", request));
}
use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.
the class PreCheckDataRelationsValidationHookTest method categoryComboWithTwoCategories.
private CategoryCombo categoryComboWithTwoCategories() {
char uniqueIdentifier = 'A';
CategoryOption co1 = createCategoryOption(uniqueIdentifier);
Category ca1 = createCategory(uniqueIdentifier, co1);
CategoryOption co2 = createCategoryOption(uniqueIdentifier);
Category ca2 = createCategory(uniqueIdentifier, co2);
CategoryCombo cc = createCategoryCombo(uniqueIdentifier, ca1, ca2);
cc.setDataDimensionType(DataDimensionType.ATTRIBUTE);
CategoryOptionCombo aoc1 = createCategoryOptionCombo(cc, co1, co2);
cc.setOptionCombos(Sets.newHashSet(aoc1));
return cc;
}
use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.
the class PreCheckDataRelationsValidationHookTest method categoryCombo.
private CategoryCombo categoryCombo(char uniqueIdentifier) {
CategoryOption co1 = createCategoryOption(uniqueIdentifier);
CategoryOption co2 = createCategoryOption(uniqueIdentifier);
Category ca = createCategory(uniqueIdentifier, co1, co2);
CategoryCombo cc = createCategoryCombo(uniqueIdentifier, ca);
cc.setDataDimensionType(DataDimensionType.ATTRIBUTE);
CategoryOptionCombo aoc1 = createCategoryOptionCombo(cc, co1);
CategoryOptionCombo aoc2 = createCategoryOptionCombo(cc, co2);
cc.setOptionCombos(Sets.newHashSet(aoc1, aoc2));
return cc;
}
use of org.hisp.dhis.category.Category in project dhis2-core by dhis2.
the class CsvImportServiceTest method testImportCategories.
@Test
void testImportCategories() throws IOException {
InputStream in = new ClassPathResource("csv/categories.csv").getInputStream();
Metadata metadata = csvImportService.fromCsv(in, new CsvImportOptions().setImportClass(CsvImportClass.CATEGORY).setFirstRowIsHeader(true));
assertEquals(3, metadata.getCategories().size());
Category gender = metadata.getCategories().get(0);
Category ageGroup = metadata.getCategories().get(1);
Category partner = metadata.getCategories().get(2);
assertEquals("Gender", gender.getName());
assertEquals(DataDimensionType.DISAGGREGATION, gender.getDataDimensionType());
assertEquals("AGEGROUP", ageGroup.getCode());
assertEquals(DataDimensionType.ATTRIBUTE, partner.getDataDimensionType());
}
Aggregations