Search in sources :

Example 1 with SimpleInitValueView

use of com.google.api.codegen.viewmodel.SimpleInitValueView in project toolkit by googleapis.

the class TestCaseTransformer method requireProjectIdInSmokeTest.

private boolean requireProjectIdInSmokeTest(FieldSettingView settingsView, SurfaceNamer namer) {
    InitCodeLineView line = settingsView.initCodeLine();
    if (line.lineType() == InitCodeLineType.SimpleInitLine) {
        SimpleInitCodeLineView simpleLine = (SimpleInitCodeLineView) line;
        String projectVarName = namer.localVarReference(Name.from(InitFieldConfig.PROJECT_ID_VARIABLE_NAME));
        if (simpleLine.initValue() instanceof ResourceNameInitValueView) {
            ResourceNameInitValueView initValue = (ResourceNameInitValueView) simpleLine.initValue();
            return initValue.formatArgs().contains(projectVarName);
        } else if (simpleLine.initValue() instanceof ResourceNameOneofInitValueView) {
            ResourceNameOneofInitValueView initValue = (ResourceNameOneofInitValueView) simpleLine.initValue();
            ResourceNameInitValueView subValue = initValue.specificResourceNameView();
            return subValue.formatArgs().contains(projectVarName);
        } else if (simpleLine.initValue() instanceof SimpleInitValueView) {
            SimpleInitValueView initValue = (SimpleInitValueView) simpleLine.initValue();
            return initValue.initialValue().equals(projectVarName);
        } else if (simpleLine.initValue() instanceof FormattedInitValueView) {
            FormattedInitValueView initValue = (FormattedInitValueView) simpleLine.initValue();
            return initValue.formatArgs().contains(projectVarName);
        }
    }
    return false;
}
Also used : ResourceNameInitValueView(com.google.api.codegen.viewmodel.ResourceNameInitValueView) SimpleInitCodeLineView(com.google.api.codegen.viewmodel.SimpleInitCodeLineView) InitCodeLineView(com.google.api.codegen.viewmodel.InitCodeLineView) SimpleInitCodeLineView(com.google.api.codegen.viewmodel.SimpleInitCodeLineView) SimpleInitValueView(com.google.api.codegen.viewmodel.SimpleInitValueView) FormattedInitValueView(com.google.api.codegen.viewmodel.FormattedInitValueView) ResourceNameOneofInitValueView(com.google.api.codegen.viewmodel.ResourceNameOneofInitValueView)

Aggregations

FormattedInitValueView (com.google.api.codegen.viewmodel.FormattedInitValueView)1 InitCodeLineView (com.google.api.codegen.viewmodel.InitCodeLineView)1 ResourceNameInitValueView (com.google.api.codegen.viewmodel.ResourceNameInitValueView)1 ResourceNameOneofInitValueView (com.google.api.codegen.viewmodel.ResourceNameOneofInitValueView)1 SimpleInitCodeLineView (com.google.api.codegen.viewmodel.SimpleInitCodeLineView)1 SimpleInitValueView (com.google.api.codegen.viewmodel.SimpleInitValueView)1