def execute(self): datas = self.getDatas() name = datas["name"] privates = "" for data in self.getProperties(): privates += " private %s %s;\n" % (data[1], data[0]) prefix = "" methods = "" properties = "" requires = "" p_list = self.getProperties() length = len(p_list) for i in range(length): last = i == length - 1 data = p_list[i] upper = TemplateUtils.splitUpper(data[0], "") properties += "filter.set%s(TestCase.ANY_%s);\n" % (upper, data[1].upper()) methods += prefix methods += TemplateUtils.get("filter-method-test").format(upper=upper, uppertype=data[1].upper()) prefix = "\n\n" requires += REQUIRE_TEMPLATE.format(upper, str(not last).lower()) upper = TemplateUtils.splitUpper(name, "") return TemplateUtils.get("filter-test").format(packet=datas["package"], interface=upper, \ testunit=methods, properties=properties, requires=requires)
def execute(self): datas = self.getDatas() name = datas["name"] privates = "" for data in self.getProperties(): privates += " private %s %s;\n" % (data[1], data[0]) prefix = "" methods = "" properties = "" requires = "" p_list = self.getProperties() length = len(p_list) for i in range(length): last = i == length - 1 data = p_list[i] upper = TemplateUtils.splitUpper(data[0], "") properties += "filter.set%s(TestCase.ANY_%s);\n" % ( upper, data[1].upper()) methods += prefix methods += TemplateUtils.get("filter-method-test").format( upper=upper, uppertype=data[1].upper()) prefix = "\n\n" requires += REQUIRE_TEMPLATE.format(upper, str(not last).lower()) upper = TemplateUtils.splitUpper(name, "") return TemplateUtils.get("filter-test").format(packet=datas["package"], interface=upper, \ testunit=methods, properties=properties, requires=requires)
def execute(self): datas = self.getDatas() name = datas["name"] camel = TemplateUtils.splitCamel(name) entityName = TemplateUtils.splitUpper(name, "-").lower() upper = TemplateUtils.splitUpper(name, "") lower = TemplateUtils.splitLower(name) return TemplateUtils.get("web-model").format(packet=datas["package"], key=datas["key"], \ camel=camel, interface=upper, entityName=entityName, name=lower)
def execute(self): datas = self.getDatas() name = datas["name"] camel = TemplateUtils.splitCamel(name) entityName = TemplateUtils.splitUpper(name, "-").lower() upper = TemplateUtils.splitUpper(name, "") lower = TemplateUtils.splitLower(name) return TemplateUtils.get("web-model-test").format(packet=datas["package"], key=datas["key"], \ camel=camel, interface=upper, entityName=entityName, name=lower)
def execute(self): datas = self.getDatas() name = datas["name"] privates = "" for data in self.getProperties(): privates += " private %s %s;\n" % (data[1], data[0]) prefix = "" methods = "" for data in self.getProperties(): methods += prefix if data[1] == "boolean": methods += self._generateIsMethod(data[0], data[1]) else: methods += self._generateGetMethod(data[0], data[1]) prefix = "\n\n" methods += prefix methods += self._generateSetMethod(data[0], data[1]) upper = TemplateUtils.splitUpper(name, "") return TemplateUtils.get("implement") % (datas["package"], upper, datas["author"], upper, \ datas["abstract"], datas["key"], upper, privates, methods)
def execute(self): datas = self.getDatas() name = datas["name"] labels = "" fill = "" fillForm = "" assertForm = "" create = "" assertNotForm = "" properties = Utils.formProperties(self.getProperties()) for data in properties: labels += self._generateLabels(data[0], data[1]) fill += self._generateFill(name, data[0], data[1]) fillForm += self._generateFillForm(data[0], data[1]) assertForm += self._generateAssertForm(name, data[0], data[1]) create += self._generateCreate(name, data[0], data[1]) assertNotForm += self._generateAssertNotForm( name, data[0], data[1]) upper = TemplateUtils.splitUpper(name, "") camel = TemplateUtils.splitCamel(name) return TemplateUtils.get("form-test").format(packet=datas["package"], entitykey=datas["key"], interface=upper, labelAmount=len(properties), \ camel=camel, labels=labels, fill=fill, fillForm=fillForm, assertForm=assertForm, \ create=create, assertNotForm=assertNotForm)
def execute(self): datas = self.getDatas() name = datas["name"] labels = "" fill = "" fillForm = "" assertForm = "" create = "" assertNotForm = "" properties = Utils.formProperties(self.getProperties()) for data in properties: labels += self._generateLabels(data[0], data[1]) fill += self._generateFill(name, data[0], data[1]) fillForm += self._generateFillForm(data[0], data[1]) assertForm += self._generateAssertForm(name, data[0], data[1]) create += self._generateCreate(name, data[0], data[1]) assertNotForm += self._generateAssertNotForm(name, data[0], data[1]) upper = TemplateUtils.splitUpper(name, "") camel = TemplateUtils.splitCamel(name) return TemplateUtils.get("form-test").format(packet=datas["package"], entitykey=datas["key"], interface=upper, labelAmount=len(properties), \ camel=camel, labels=labels, fill=fill, fillForm=fillForm, assertForm=assertForm, \ create=create, assertNotForm=assertNotForm)
def execute(self): datas = self.getDatas() name = datas["name"] privates = "" prefix = "" methods = "" fill = "" extract = "" labels = "" for data in Utils.formProperties(self.getProperties()): privates += " private %s %s;\n" % (data[1], data[0]) methods += prefix if data[1] == "boolean": methods += self._generateIsMethod(data[0], data[1]) else: methods += self._generateGetMethod(data[0], data[1]) prefix = "\n\n" methods += prefix methods += self._generateSetMethod(data[0], data[1]) fill += self._generateFill(name, data[0], data[1]) extract += self._generateExtract(name, data[0], data[1]) labels += self._generateLabels(data[0], data[1]) upper = TemplateUtils.splitUpper(name, "") lower = TemplateUtils.splitLower(name) camel = TemplateUtils.splitCamel(name) getterSetter = privates + "\n" + methods return TemplateUtils.get("form").format(packet=datas["package"], interface=upper, auther=datas["author"], \ entitykey=datas["key"], variable=getterSetter, name=lower, camel=camel, \ fill=fill, extract=extract, labels=labels)
def execute(self): datas = self.getDatas() name = datas["name"] columns = "\"entity.id\"" for data in self.getProperties(): columns += ", \"entity.%s\"" % data[0] camel = TemplateUtils.splitCamel(name) entityName = TemplateUtils.splitUpper(name, "-").lower() upper = TemplateUtils.splitUpper(name, "") lower = TemplateUtils.splitLower(name) return TemplateUtils.get("admin-controller-test").format(packet=datas["package"], key=datas["key"], columns=columns, \ camel=camel, interface=upper, entityName=entityName, name=lower)
def _generateSetMethod(self, name, t): upper = TemplateUtils.splitUpper(name, "") lower = TemplateUtils.splitLower(name) return TemplateUtils.get("form-set-method-impl").format(ftype=t, upper=upper, name=name, callname=lower)
def execute(self): datas = self.getDatas() name = datas["name"] privates = "" for data in self.getProperties(): privates += " private %s %s;\n" % (data[1], data[0]) prefix = "" methods = "" requires = "" hashAppends = "" equalsAppends = "" for data in self.getProperties(): upper = TemplateUtils.splitUpper(data[0], "") lower = TemplateUtils.splitCamel(data[0]) if requires != "": requires += " || " requires += "has%s()" % upper hashAppends += ".append(%s)" % lower equalsAppends += "\t\t\tb.append(%s, rhs.%s);\n" % (lower, lower) methods += prefix methods += self._generateHasMethod(data[0], data[1]) prefix = "\n\n" methods += prefix if data[1] == "boolean": methods += self._generateIsMethod(data[0], data[1]) else: methods += self._generateGetMethod(data[0], data[1]) methods += prefix methods += self._generateSetMethod(data[0], data[1]) upper = TemplateUtils.splitUpper(name, "") lower = TemplateUtils.splitLower(name) camel = TemplateUtils.splitCamel(name) getterSetter = privates + "\n" + methods return TemplateUtils.get("filter").format(packet=datas["package"], interface=upper, auther=datas["author"], \ entitykey=datas["key"], variable=getterSetter, name=lower, camel=camel, \ required=requires, hashAppends=hashAppends, equalsAppends=equalsAppends)
def execute(self): datas = self.getDatas() name = datas["name"] prefix = "" methods = "" for data in self.getProperties(): methods += prefix if data[1] == "boolean": methods += self._generateIsMethod(data[0], data[1]) else: methods += self._generateGetMethod(data[0], data[1]) prefix = "\n\n" methods += prefix methods += self._generateSetMethod(data[0], data[1]) upperName = TemplateUtils.splitUpper(name) upper = TemplateUtils.splitUpper(name, "") return TemplateUtils.get("interface") % \ (datas["package"], upperName, datas["author"], upper, datas["super"], datas["key"], methods)
def formProperties(properties): data = [] for name, t in properties: if t == "Name": data.append(("%sPrimary" % name, "String")) data.append(("%sThai" % name, "String")) data.append(("%sEnglish" % name, "String")) elif t == "Aliases": data.append((name, "String[]")) elif t == "int": data.append((name, "Integer")) elif t in ["boolean", "long", "double"]: data.append((name, TemplateUtils.splitUpper(t, ""))) else: data.append((name, t)) return data
def formProperties(properties): data = [] for name, t in properties: if t == "Name": data.append(("%sPrimary" % name, "String")) data.append(("%sThai" % name, "String")) data.append(("%sEnglish" % name, "String")) elif t == "Aliases": data.append((name, "String[]")) elif t == "int": data.append((name, "Integer")) elif t in ["boolean" , "long", "double"]: data.append((name, TemplateUtils.splitUpper(t, ""))) else: data.append((name, t)) return data
def _generateLabels(self, name, t): label = TemplateUtils.splitUpper(name, " ") return " Assert.assertThat(values.get(\"%s\"), CoreMatchers.equalTo(\"%s\"));\n" % (name, label)
def _generateLabels(self, name, t): label = TemplateUtils.splitUpper(name, " ") return " labels.put(\"%s\", \"%s\");\n" % (name, label)
def _generateFillForm(self, name, t): return " underTest.set%s(%s);\n" % (TemplateUtils.splitUpper(name, ""), Utils.random(t))
def _generateGetMethod(self, name, t): upper = TemplateUtils.splitUpper(name, "") full = TemplateUtils.splitFull(name) return TemplateUtils.get("test-method") % (upper, upper, upper, full, upper, full)
def execute(self): datas = self.getDatas() upper = TemplateUtils.splitUpper(datas["name"], "") return TemplateUtils.get("create-form").format(packet=datas["package"], interface=upper)
def _generateSetMethod(self, name, data_type): lower = TemplateUtils.splitLower(name) upper = TemplateUtils.splitUpper(name, "") return TemplateUtils.get("set-method") % (lower, name, lower, upper, data_type, name)
def _generateAssertForm(self, cName, name, t): upper = TemplateUtils.splitUpper(name, "") variable = TemplateUtils.splitCamel(cName) return " Assert.assertThat(underTest.get{upper}(), CoreMatchers.equalTo({name}.get{upper}()));\n".format( upper=upper, name=variable)
def _generateFillForm(self, name, t): return " underTest.set%s(%s);\n" % ( TemplateUtils.splitUpper(name, ""), Utils.random(t))
def _generateHasMethod(self, name, t): upper = TemplateUtils.splitUpper(name, "") lower = TemplateUtils.splitLower(name) return TemplateUtils.get("filter-has-method").format(ftype=t, upper=upper, name=name, callname=lower)
def _generateSetMethod(self, name, data_type): upper = TemplateUtils.splitUpper(name, "") return TemplateUtils.get("set-method-impl") % (upper, data_type, name, name, name)
def _generateExtract(self, cName, name, t): lower = TemplateUtils.splitCamel(cName) upper = TemplateUtils.splitUpper(name, "") return TEMPLATE_EXTRACT.format(param=name, name=lower, upperParam=upper)
def _generateFill(self, cName, name, t): lower = TemplateUtils.splitCamel(cName) upper = TemplateUtils.splitUpper(name, "") return TEMPLATE_PARAMETER_SET.format(param=name, name=lower, upperParam=upper)
def _generateFill(self, cName, name, t): lower = TemplateUtils.splitCamel(cName) upper = TemplateUtils.splitUpper(name, "") return " Assert.assertThat({name}.get{upper}(), CoreMatchers.equalTo(underTest.get{upper}()));\n".format(upper=upper, name=lower)
def _generateLabels(self, name, t): label = TemplateUtils.splitUpper(name, " ") return " Assert.assertThat(values.get(\"%s\"), CoreMatchers.equalTo(\"%s\"));\n" % ( name, label)
def _generateFill(self, cName, name, t): lower = TemplateUtils.splitCamel(cName) upper = TemplateUtils.splitUpper(name, "") return " Assert.assertThat({name}.get{upper}(), CoreMatchers.equalTo(underTest.get{upper}()));\n".format( upper=upper, name=lower)
def execute(self): datas = self.getDatas() upper = TemplateUtils.splitUpper(datas["name"], "") return TemplateUtils.get("update-form-test").format( packet=datas["package"], interface=upper)
def _generateIsMethod(self, name, data_type): upper = TemplateUtils.splitUpper(name, "") return TemplateUtils.get("is-method-impl") % (data_type, upper, name)
def _generateCreate(self, cName, name, t): upper = TemplateUtils.splitUpper(name, "") variable = TemplateUtils.splitCamel(cName); return " {name}.set{upper}({value});\n".format(upper=upper, name=variable, value=Utils.random(t))
def _generateIsMethod(self, name, t): upper = TemplateUtils.splitUpper(name, "") return TemplateUtils.get("test-is-method") % (upper, upper, upper, upper)
def _generateAssertForm(self, cName, name, t): upper = TemplateUtils.splitUpper(name, "") variable = TemplateUtils.splitCamel(cName); return " Assert.assertThat(underTest.get{upper}(), CoreMatchers.equalTo({name}.get{upper}()));\n".format(upper=upper, name=variable)
def _generateCreate(self, cName, name, t): upper = TemplateUtils.splitUpper(name, "") variable = TemplateUtils.splitCamel(cName) return " {name}.set{upper}({value});\n".format( upper=upper, name=variable, value=Utils.random(t))