ConvertRecord { public static void fillTodoCustomPropertyInfo(List<Todo> todos, List<PropertyWithValueAndId> customProperties, SetMultimap<Integer, Integer> todoCustomPropertyMap) { int nextPropertyId = 0; for(Todo todo : todos){ if(todo.isSetCustomPropertyToValue()){ for(Map.Entry<String, String> entry : todo.getCustomPropertyToValue().entrySet()){ customProperties.add(new PropertyWithValueAndId(nextPropertyId, entry.getKey(), entry.getValue())); todoCustomPropertyMap.put(todo.getTodoId(), nextPropertyId); nextPropertyId++; } } } } private  ConvertRecord(); static List<RiskCategory> convertRiskCategories(List<CSVRecord> records); static Serializer<RiskCategory> riskCategorySerializer(); static List<Risk> convertRisks(List<CSVRecord> records, Map<Integer, RiskCategory> categories); static Serializer<Risk> riskSerializer(); static Map<String, Set<String>> convertCustomProperties(List<CSVRecord> records); static Map<Integer, PropertyWithValue> convertCustomPropertiesById(List<CSVRecord> records); static void fillTodoCustomPropertyInfo(List<Todo> todos, List<PropertyWithValueAndId> customProperties, SetMultimap<Integer, Integer> todoCustomPropertyMap); static Serializer<PropertyWithValueAndId> customPropertiesSerializer(); static List<Todo> convertTodos(List<CSVRecord> records); static Serializer<Todo> todoSerializer(); static List<Obligation> convertObligation(List<CSVRecord> records); static Serializer<Obligation> obligationSerializer(); static void putToTodos(Map<Integer, Obligation> obligations, Map<Integer, Todo> todos, Map<Integer, Set<Integer>> obligationTodo); static List<LicenseType> convertLicenseTypes(List<CSVRecord> records); static Serializer<LicenseType> licenseTypeSerializer(); static List<License> fillLicenses(List<CSVRecord> records, Map<Integer, LicenseType> licenseTypeMap, Map<Integer, Todo> todoMap, Map<Integer, Risk> riskMap, Map<String, Set<Integer>> licenseTodo, Map<String, Set<Integer>> licenseRisk); static Serializer<License> licenseSerializer(); static Map<String, Set<Integer>> convertRelationalTable(List<CSVRecord> records); static Map<Integer, Set<Integer>> convertRelationalTableWithIntegerKeys(List<CSVRecord> records); @NotNull static SetMultimap<Integer, Integer> getTodoToObligationMap(List<Todo> todos); @NotNull static SetMultimap<String, Integer> getLicenseToTodoMap(List<License> licenses); @NotNull static SetMultimap<String, Integer> getLicenseToRiskMap(List<License> licenses); static void addLicenses(LicenseService.Iface licenseClient, List<License> licensesToAdd, Logger log, User user); static List<List<String>> serialize(List<T> in, Serializer<T> serializer); static List<List<String>> serialize(List<T> in, List<String> headers, Function<T, List<String>> function); @NotNull static List<List<String>> serialize(SetMultimap<T, U> aToB, List<String> headers); static Gson gson; }
@Test public void testFillTodoCustomPropertyInfoEmpty() throws Exception { List<ConvertRecord.PropertyWithValueAndId> customProperties = new ArrayList<>(); SetMultimap<Integer, Integer> todoCustomPropertyMap = HashMultimap.create(); fillTodoCustomPropertyInfo(Collections.EMPTY_LIST, customProperties, todoCustomPropertyMap); assertThat(customProperties.size(), is(0)); assertThat(todoCustomPropertyMap.size(), is(0)); }
@Test public void testFillTodoCustomPropertyInfoFull() throws Exception { List<ConvertRecord.PropertyWithValueAndId> customProperties = new ArrayList<>(); SetMultimap<Integer, Integer> todoCustomPropertyMap = HashMultimap.create(); fillTodoCustomPropertyInfo(todos, customProperties, todoCustomPropertyMap); assertThat(customProperties.size(), is(3)); assertThat(todoCustomPropertyMap.size(), is(3)); int id = todoCustomPropertyMap.get(1).stream().findFirst().get(); assertThat(customProperties.get(id).getProperty(), is("A")); assertThat(customProperties.get(id).getValue(), is("A1")); }