use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class GoConfigMigrationIntegrationTest method shouldMigrateMaterialFolderAttributeToDest.
@Test
public void shouldMigrateMaterialFolderAttributeToDest() throws Exception {
CruiseConfig cruiseConfig = loadConfigFileWithContent(ConfigFileFixture.VERSION_2);
MaterialConfig actual = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("multiple")).materialConfigs().first();
assertThat(actual.getFolder(), is("part1"));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class MaterialConnectivityServiceTest method shouldCheckConnections.
@Theory
public void shouldCheckConnections(RequestDataPoints dataPoints) throws Exception {
MaterialConfig config = dataPoints.material.config();
MaterialConnectivityService spy = spy(service);
doReturn(dataPoints.klass).when(spy).getMaterialClass(dataPoints.material);
doReturn(dataPoints.material).when(materialConfigConverter).toMaterial(config);
ValidationBean actual = spy.checkConnection(config, executionContext);
assertThat(actual, is(dataPoints.expectedResult));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class InternalMaterialsControllerV1 method createMergedMap.
private Map<MaterialConfig, MaterialInfo> createMergedMap(Map<MaterialConfig, Boolean> materialConfigs, Map<String, Modification> modificationsMap, Collection<MaintenanceModeService.MaterialPerformingMDU> runningMDUs, ServerHealthStates allLogs) {
HashMap<MaterialConfig, MaterialInfo> map = new HashMap<>();
if (materialConfigs.isEmpty()) {
return map;
}
materialConfigs.forEach((materialConfig, hasOperatePermission) -> {
if (!materialConfig.getType().equals(DependencyMaterialConfig.TYPE)) {
Material material = materialConfigConverter.toMaterial(materialConfig);
List<HealthStateScope> scopes = asList(forMaterial(material), forMaterialUpdate(material), forMaterialConfig(materialConfig));
List<ServerHealthState> logs = allLogs.stream().filter((log) -> scopes.contains(log.getType().getScope())).collect(toList());
Modification mod = modificationsMap.getOrDefault(materialConfig.getFingerprint(), null);
MaintenanceModeService.MaterialPerformingMDU mduInfo = runningMDUs.stream().filter((mdu) -> mdu.getMaterial().getFingerprint().equals(materialConfig.getFingerprint())).findFirst().orElse(null);
boolean isMDUInProgress = mduInfo != null;
Timestamp updateStartTime = isMDUInProgress ? mduInfo.getTimestamp() : null;
map.put(materialConfig, new MaterialInfo(mod, hasOperatePermission, isMDUInProgress, updateStartTime, logs));
}
});
return map;
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class InternalMaterialsControllerV1 method index.
public String index(Request request, Response response) throws Exception {
Map<MaterialConfig, Boolean> materialConfigs = materialConfigService.getMaterialConfigsWithPermissions(currentUsernameString());
Map<String, Modification> modifications = materialService.getLatestModificationForEachMaterial();
Collection<MaintenanceModeService.MaterialPerformingMDU> runningMDUs = maintenanceModeService.getRunningMDUs();
ServerHealthStates logs = serverHealthService.logs();
Map<MaterialConfig, MaterialInfo> mergedMap = createMergedMap(materialConfigs, modifications, runningMDUs, logs);
final String etag = etagFor(mergedMap);
if (fresh(request, etag)) {
return notModified(response);
}
setEtagHeader(response, etag);
return writerForTopLevelObject(request, response, writer -> MaterialWithModificationsRepresenter.toJSON(writer, mergedMap));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class InternalMaterialsControllerV1 method triggerUpdate.
public String triggerUpdate(Request request, Response response) {
String fingerprint = request.params(FINGERPRINT);
MaterialConfig materialConfig = materialConfigService.getMaterialConfig(currentUsernameString(), fingerprint);
if (materialUpdateService.updateMaterial(materialConfigConverter.toMaterial(materialConfig))) {
response.status(HttpStatus.CREATED.value());
return MessageJson.create("OK");
} else {
response.status(HttpStatus.CONFLICT.value());
return MessageJson.create("Update already in progress.");
}
}
Aggregations