Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoloboschi committed Oct 16, 2023
1 parent 1b3fc3d commit 286f631
Show file tree
Hide file tree
Showing 3 changed files with 321 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,7 @@ public static void validateAgentModelFromClass(
Class modelClazz,
Map<String, Object> asMap,
boolean allowUnknownProperties) {
final EntityRef ref =
() ->
"agent configuration (agent: '%s', type: '%s')"
.formatted(
agentConfiguration.getName() == null
? agentConfiguration.getId()
: agentConfiguration.getName(),
agentConfiguration.getType());
validateModelFromClass(ref, modelClazz, asMap, allowUnknownProperties);
validateModelFromClass(new AgentEntityRef(agentConfiguration), modelClazz, asMap, allowUnknownProperties);
}

@AllArgsConstructor
Expand Down Expand Up @@ -199,6 +191,22 @@ public String ref() {
}
}

@AllArgsConstructor
public static class AgentEntityRef implements EntityRef {

private final AgentConfiguration agentConfiguration;

@Override
public String ref() {
return "agent configuration (agent: '%s', type: '%s')"
.formatted(
agentConfiguration.getName() == null
? agentConfiguration.getId()
: agentConfiguration.getName(),
agentConfiguration.getType());
}
}

@SneakyThrows
public static void validateAssetModelFromClass(
AssetDefinition asset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ protected Map<String, Object> computeAgentConfiguration(
// get the datasource configuration and inject it into the agent configuration
String resourceId = (String) originalConfiguration.remove("datasource");
if (resourceId == null) {
throw new IllegalStateException(
"datasource is required but this exception should have been raised before ?");
throw new IllegalArgumentException(ClassConfigValidator.formatErrString(new ClassConfigValidator.AgentEntityRef(agentConfiguration), "datasource", "is required"));
}
generateDataSourceConfiguration(
resourceId,
Expand Down
Loading

0 comments on commit 286f631

Please sign in to comment.