Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
    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)
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
 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)
Ejemplo n.º 10
0
    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)
Ejemplo n.º 11
0
 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 execute(self):
        datas = self.getDatas()

        entityName = datas["name"]

        return TemplateUtils.get("test-repository-hibernate").format(
            entityName)
Ejemplo n.º 13
0
    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)
Ejemplo n.º 14
0
    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)
Ejemplo n.º 15
0
 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
Ejemplo n.º 16
0
 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
Ejemplo n.º 17
0
    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)
Ejemplo n.º 18
0
 def _generateSetMethod(self, name, data_type):
     upper = TemplateUtils.splitUpper(name, "")
     
     return TemplateUtils.get("set-method-impl") % (upper, data_type, name, name, name)
Ejemplo n.º 19
0
 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)
Ejemplo n.º 20
0
    def _generateGetMethod(self, name, t):
        upper = TemplateUtils.splitUpper(name, "")
        full = TemplateUtils.splitFull(name)

        return TemplateUtils.get("test-method") % (upper, upper, upper, full,
                                                   upper, full)
Ejemplo n.º 21
0
 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)
Ejemplo n.º 22
0
 def execute(self):
     datas = self.getDatas()
     upper = TemplateUtils.splitUpper(datas["name"], "")
     
     return TemplateUtils.get("create-form").format(packet=datas["package"], interface=upper)
Ejemplo n.º 23
0
 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)
Ejemplo n.º 24
0
 def _generateFillForm(self, name, t): 
     return "            underTest.set%s(%s);\n" % (TemplateUtils.splitUpper(name, ""), Utils.random(t))
Ejemplo n.º 25
0
 def _generateExtract(self, cName, name, t):
     lower = TemplateUtils.splitCamel(cName)
     upper = TemplateUtils.splitUpper(name, "")
     return TEMPLATE_EXTRACT.format(param=name,
                                    name=lower,
                                    upperParam=upper)
Ejemplo n.º 26
0
 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)
Ejemplo n.º 27
0
 def _generateLabels(self, name, t):
     label = TemplateUtils.splitUpper(name, " ")
     return "            labels.put(\"%s\", \"%s\");\n" % (name, label)
Ejemplo n.º 28
0
 def _generateLabels(self, name, t): 
     label = TemplateUtils.splitUpper(name, " ")
     return "            labels.put(\"%s\", \"%s\");\n" % (name, label)
Ejemplo n.º 29
0
    def _generateIsMethod(self, name, t):
        upper = TemplateUtils.splitUpper(name, "")

        return TemplateUtils.get("test-is-method") % (upper, upper, upper,
                                                      upper)
Ejemplo n.º 30
0
 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))
Ejemplo n.º 31
0
 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)
Ejemplo n.º 32
0
    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)
Ejemplo n.º 33
0
 def _generateLabels(self, name, t): 
     label = TemplateUtils.splitUpper(name, " ")
     return "            Assert.assertThat(values.get(\"%s\"), CoreMatchers.equalTo(\"%s\"));\n" % (name, label)
Ejemplo n.º 34
0
 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))
Ejemplo n.º 35
0
 def _generateExtract(self, cName, name, t):
     lower = TemplateUtils.splitCamel(cName)
     upper = TemplateUtils.splitUpper(name, "")
     return TEMPLATE_EXTRACT.format(param=name, name=lower, upperParam=upper)
Ejemplo n.º 36
0
 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)
Ejemplo n.º 37
0
    def execute(self):
        datas = self.getDatas()
        upper = TemplateUtils.splitUpper(datas["name"], "")

        return TemplateUtils.get("update-form-test").format(
            packet=datas["package"], interface=upper)
Ejemplo n.º 38
0
 def _generateGetMethod(self, name, t):
     upper = TemplateUtils.splitUpper(name, "")
     full = TemplateUtils.splitFull(name)
     
     return TemplateUtils.get("test-method") % (upper, upper, upper, full, upper, full)
Ejemplo n.º 39
0
 def _generateFillForm(self, name, t):
     return "            underTest.set%s(%s);\n" % (
         TemplateUtils.splitUpper(name, ""), Utils.random(t))
Ejemplo n.º 40
0
 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)
Ejemplo n.º 41
0
 def _generateIsMethod(self, name, t):
     upper = TemplateUtils.splitUpper(name, "")
     
     return TemplateUtils.get("test-is-method") % (upper, upper, upper, upper)
Ejemplo n.º 42
0
 def _generateLabels(self, name, t):
     label = TemplateUtils.splitUpper(name, " ")
     return "            Assert.assertThat(values.get(\"%s\"), CoreMatchers.equalTo(\"%s\"));\n" % (
         name, label)
Ejemplo n.º 43
0
 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)
Ejemplo n.º 44
0
 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()

        entityName = datas["name"]

        return TemplateUtils.get("test-repository-hibernate").format(entityName)
Ejemplo n.º 46
0
 def _generateIsMethod(self, name, data_type):
     upper = TemplateUtils.splitUpper(name, "")
     
     return TemplateUtils.get("is-method-impl") % (data_type, upper, name)