private void assertModels(LogicalModel lmodel, Model model, String domainId) { assertNotNull(model); assertEquals(lmodel.getId(), model.getModelId()); assertEquals(domainId, model.getGroupId()); assertEquals(lmodel.getName(DEFAULT_LOCALE), model.getName()); assertEquals(lmodel.getDescription(DEFAULT_LOCALE), model.getDescription()); }
@Override public Model getModel(String id) { Model model = createModel(); if (model.getId().equals(id)) { return model; } else { return null; } }
@Test public void testCreateThinModel() { LogicalColumn column = createMockColumn( "id_column", "name_column", "description_column", DataType.STRING, FieldType.ATTRIBUTE); List<LogicalColumn> listColumns = new ArrayList<LogicalColumn>(1); listColumns.add(column); Category category = createMockCategory("id_category", "name_category", "description_category", listColumns); List<Category> listCategories = new ArrayList<Category>(1); listCategories.add(category); LogicalModel lmodel = createMockModel("id", "name", "description", listCategories); Model model = spyMetadataServiceUtil.createThinModel(lmodel, DOMAIN_ID); assertModels(lmodel, model, DOMAIN_ID); assertEquals(2, model.getElements().length); Element elemCat = model.getElements()[0]; assertElements(category, elemCat); Element elemCol = model.getElements()[1]; assertColumns(column, elemCol, category.getId()); }
private Model createModel() { // only one model for this... ModelInfo info = createModelInfo(); Model model = new Model(); Element elements[] = new Element[3]; HashMap<String, String> elementCapabilities = new HashMap<String, String>(); elementCapabilities.put(Element.CAPABILITY_CAN_SEARCH, "false"); elementCapabilities.put(Element.CAPABILITY_CAN_SORT, "false"); Element groupElement = new Element(); groupElement.setElementType(FieldType.DIMENSION.name()); groupElement.setHorizontalAlignment(Alignment.LEFT.name()); groupElement.setId("element1"); groupElement.setName("Element 1"); groupElement.setDescription("Description 1"); groupElement.setDataType(Types.TYPE_STRING.toString()); groupElement.setCapabilities(elementCapabilities); groupElement.setIsQueryElement(false); elements[0] = groupElement; Element element1 = new Element(); element1.setElementType(FieldType.DIMENSION.name()); element1.setHorizontalAlignment(Alignment.LEFT.name()); element1.setId("element1"); element1.setName("Element 1"); element1.setDataType(Types.TYPE_STRING.toString()); element1.setCapabilities(elementCapabilities); element1.setIsQueryElement(true); elements[1] = element1; elementCapabilities.put(Element.CAPABILITY_CAN_FILTER, "false"); Element element2 = new Element(); element2.setElementType(FieldType.FACT.name()); element2.setHorizontalAlignment(Alignment.RIGHT.name()); element2.setId("element2"); element2.setName("Element 2"); element2.setDataType(Types.TYPE_NUMERIC.toString()); element2.setFormatMask("#,###.00"); element2.setCapabilities(elementCapabilities); element2.setIsQueryElement(true); element2.setAvailableAggregations(new String[] {"SUM", "MIN"}); element2.setDefaultAggregation("SUM"); element2.setHiddenForUser(false); element2.setParentId("element1"); elements[2] = element2; model.setElements(elements); model.setGroupId(info.getGroupId()); model.setDescription(info.getDescription()); model.setModelId(info.getModelId()); model.setName(info.getName()); model.setProvider(provider); HashMap<String, String> capabilities = new HashMap<String, String>(); capabilities.put("across-axis", "true"); capabilities.put("across-axis-customizable", "true"); capabilities.put("down-axis", "false"); capabilities.put("down-axis-customizable", "false"); capabilities.put("filter-axis", "false"); capabilities.put("filter-axis-customizable", "false"); capabilities.put("sortable", "false"); model.setCapabilities(capabilities); return model; }