@JsonCreator(mode = JsonCreator.Mode.DELEGATING) static ImmutableProject fromJson(Json json) { Project.Builder builder = new Project.Builder(); if (json.name != null) { builder.name(json.name); builder.addAllSharedElements(json.sharedElements); builder.addAllUserPaths(json.userPaths); builder.addAllServers(json.servers); builder.addAllVariables(json.variables); builder.addAllPopulations(json.populations); builder.addAllScenarios(json.scenarios); builder.putAllProjectSettings(json.projectSettings); return (ImmutableProject) builder.build();
private void readScript(final ImmutableProject.Builder projectBuilder, final File projectFolder) { try { currentScriptFolder = projectFolder; eventListener.startScript(currentScriptFolder.getName()); final ProjectFileReader projectFileReader = new ProjectFileReader(this, eventListener, projectFolder); final Map<String, String> actionsMap = projectFileReader.getAllActionsMap(); if (actionsMap.isEmpty()) { LOGGER.error("No action in the map. Ignore the script."); return; } final ParameterFileReader parameterFileReader = new ParameterFileReader(this, projectFileReader, projectFolder); final ImmutableUserPath.Builder userPathBuilder = ImmutableUserPath.builder(); final boolean hasAction = manageActions(projectFolder, projectFileReader, actionsMap, projectBuilder, userPathBuilder); final UserPath userPath = userPathBuilder.name(projectFileReader.getVirtualUserName()).build(); if (!hasAction) { LOGGER.error("No Init / Actions / End. Ignore the script."); return; } projectBuilder.addAllVariables(parameterFileReader.getAllVariables()).addUserPaths(userPath); } finally { eventListener.endScript(); } }
@Override public synchronized Project read() { try { final ImmutableProject.Builder projectBuilder = Project.builder().name(this.projectName); final List<File> projectFolders = getProjectFolders(); final int totalScriptNumber = projectFolders.size(); eventListener.startReadingScripts(totalScriptNumber); if (projectFolders.isEmpty()) { throw new IllegalStateException("No Load Runner project found."); } for (final File projectFolder : projectFolders) { readScript(projectBuilder, projectFolder); } projectBuilder.servers(currentProjectServers.values()); return projectBuilder.build(); } finally { eventListener.endReadingScripts(); } }
/** * Creates an immutable copy of a {@link Project} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable Project instance */ public static ImmutableProject copyOf(Project instance) { if (instance instanceof ImmutableProject) { return (ImmutableProject) instance; } return new Project.Builder() .from(instance) .build(); }
static Builder builder() { return new Builder(); } }