Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import static modelengine.fitframework.inspection.Validation.notNull;
import static modelengine.fitframework.util.ObjectUtils.cast;
import static modelengine.jade.store.tool.upload.support.BasicValidator.buildBlankParserException;
import static modelengine.jade.store.tool.upload.support.BasicValidator.buildEmptyParserException;
import static modelengine.jade.store.tool.upload.support.BasicValidator.buildNullParserException;
import static modelengine.jade.store.tool.upload.support.BasicValidator.buildParserException;

Expand Down Expand Up @@ -134,14 +133,14 @@ private void validateParams(ParameterEntity param, String fileName) {
if (!param.getType().equals(OBJECT)) {
throw buildParserException("The type of the field 'parameters' in 'tools.json' must is: 'object'.");
}
this.validateProperties(param.getProperties());
this.validateRequired(param, fileName);
Map<String, Object> properties = param.getProperties();
if (MapUtils.isNotEmpty(properties)) {
this.validateProperties(properties);
this.validateRequired(param, fileName);
}
}

private void validateProperties(Map<String, Object> properties) {
if (MapUtils.isEmpty(properties)) {
throw buildEmptyParserException(TOOLS_JSON, SCHEMA + DOT + PARAMETERS);
}
properties.forEach((key, value) -> validateProperty(cast(value), PARAMETERS, key));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ void testUploadPluginsWithWrongName() throws IOException {
@DisplayName("当选择部分工具上传时,成功")
void shouldOkWhenValidateSelectTools() {
List<String> selectTools = Arrays.asList(
"defGroup-weather-Rain.implGroup-weather-Rain-A.rain_today.a_rain_today",
"defGroup-weather-Rain.implGroup-weather-Rain-A.rain_tomorrow.a_rain_today");
"defGroup_weather_Rain.implGroup_weather_rain_city_a.rain_today.city_a_rain_tomorrow",
"defGroup_weather_Rain.implGroup_weather_rain_city_b.rain_tomorrow.city_b_rain_tomorrow");
ToolProcessor toolProcessor = new ToolProcessor(this.serializer);
DefinitionProcessor defProcessor = new DefinitionProcessor(this.serializer);
ToolJsonEntity toolJsonEntity = getFileInfo(new File(NEW_TOOL_JSON), serializer, ToolJsonEntity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void setup() {
@Test
@DisplayName("当定义组存在重复时,删除定义组")
void shouldExWhenDefGroupRepeat() {
when(this.defGroupService.findExistDefGroups(anySet())).thenReturn(Arrays.asList("defGroup-weather-Rain"));
when(this.defGroupService.findExistDefGroups(anySet())).thenReturn(Arrays.asList("defGroup_weather_Rain"));
int size = this.defGroups.size();
validateDefAndToolRepeat(this.defGroups, this.toolGroups, this.toolGroupService, this.defGroupService);
assertThat(this.defGroups.size()).isEqualTo(size - 1);
Expand Down Expand Up @@ -243,7 +243,7 @@ void shouldExWhenToolNameInToolGroupRepeat() {
validateDefAndToolRepeat(this.defGroups, this.toolGroups, this.toolGroupService, this.defGroupService);
}).isInstanceOf(ModelEngineException.class)
.hasMessageContaining("The current operation has duplicate property. [property='toolName', "
+ "value='implGroup-weather-Rain-A.a_rain_today']");
+ "value='implGroup_weather_rain_city_a.city_a_rain_today']");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void shouldOkWhenObjToMap() {
void shouldOkWhenBuildDefGroupMap() {
ToolJsonEntity toolJsonEntity = getFileInfo(new File(NEW_TOOL_JSON), serializer, ToolJsonEntity.class);
Map<String, Object> defGroupMap = buildDefGroupMap(toolJsonEntity);
assertThat(defGroupMap.size()).isEqualTo(2);
assertThat(defGroupMap.size()).isEqualTo(1);
}

@Test
Expand Down
Loading