use of jetbrains.buildServer.serverSide.parameters.ParameterDescriptionFactory in project teamcity-rest by JetBrains.
the class BuildTypeRequestTest method testParameterTypeResourses.
@Test
public void testParameterTypeResourses() {
BuildTypeImpl buildType1 = registerTemplateBasedBuildType("buildType1");
ParameterFactory parameterFactory = myFixture.getSingletonService(ParameterFactory.class);
ParameterDescriptionFactory parameterDescriptionFactory = myFixture.getSingletonService(ParameterDescriptionFactory.class);
buildType1.addParameter(parameterFactory.createParameter("a1", "b10", parameterDescriptionFactory.createDescription("cType", CollectionsUtil.asMap("a", "b", "c", "d"))));
buildType1.addParameter(new SimpleParameter("a2", "b9"));
final String btLocator = "id:" + buildType1.getExternalId();
TypedParametersSubResource parametersSubResource = myBuildTypeRequest.getParametersSubResource(btLocator);
assertEquals(2, parametersSubResource.getParameters(null, "$long,property($long)").properties.size());
{
Property parameter = parametersSubResource.getParameter("a1", "$long");
assertEquals("a1", parameter.name);
assertEquals("b10", parameter.value);
assertEquals("cType a='b' c='d'", parameter.type.rawValue);
}
{
ParameterType parameterType = parametersSubResource.getParameterType("a1");
assertEquals("cType a='b' c='d'", parameterType.rawValue);
}
/*
{
assertEquals("cType", buildType1.getParameter("a1").getControlDescription().getParameterType());
assertMap(buildType1.getParameter("a1").getControlDescription().getParameterTypeArguments(), "a", "b", "c", "d");
ParameterType parameterType = new ParameterType();
parameterType.rawValue = "cType a='b1' c='d'";
ParameterType newParameterType = parametersSubResource.setParameterType("a1", parameterType);
assertEquals("cType a='b1' c='d'", newParameterType.rawValue);
assertEquals("cType", buildType1.getParameter("a1").getControlDescription().getParameterType());
assertMap(buildType1.getParameter("a1").getControlDescription().getParameterTypeArguments(), "a", "b1", "c", "d");
}
*/
}
use of jetbrains.buildServer.serverSide.parameters.ParameterDescriptionFactory in project teamcity-rest by JetBrains.
the class Property method getFromPosted.
@NotNull
public Parameter getFromPosted(@NotNull final ServiceLocator serviceLocator) {
isValid();
final ParameterFactory parameterFactory = serviceLocator.getSingletonService(ParameterFactory.class);
if (type == null || type.rawValue == null) {
return parameterFactory.createSimpleParameter(name, value);
}
// workaround for https://youtrack.jetbrains.com/issue/TW-41041
final ParameterDescriptionFactory parameterDescriptionFactory = serviceLocator.getSingletonService(jetbrains.buildServer.serverSide.parameters.ParameterDescriptionFactory.class);
try {
parameterDescriptionFactory.parseDescription(type.rawValue);
} catch (ParseException e) {
throw new BadRequestException("Wrong parameter type \"" + type.rawValue + "\" provided: " + e.getMessage());
}
return parameterFactory.createTypedParameter(name, value, type.rawValue);
}
Aggregations