Skip to content

Instantly share code, notes, and snippets.

View edipofederle's full-sized avatar
🏠
Working from home

Édipo Féderle edipofederle

🏠
Working from home
View GitHub Profile
function sendRequest() {
var requestID = "666";
Ext.Ajax.request({
url:'/url'
success: function(response) {
alert("Request " + requestID + " returned");
}
});
}
## From the book Clojure in Action
### A small program written in our fictitious XML-based language
<program>
<function name=addToStock>
<param name=counter></param>
<callFunction name=increment>
// Code From Clean Code Book
public void registerItem(Item item) {
if (item != null) {
ItemRegistry registry = peristentStore.getItemRegistry();
if (registry != null) {
Item existing = registry.getItem(item.getID());
if (existing.getBillingPeriod().hasRetailOwner()) {
existing.register(item);
}
}
@edipofederle
edipofederle / pom.xml
Created February 6, 2013 20:00
pom file to uml2. ecore... etc
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>XXXX</groupId>
<artifactId>XXXX</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>arch</name>
protected void registerPathmaps() {
String umlResourcePath = UMLResourcesUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath();
try {
umlResourcePath = URLDecoder.decode(umlResourcePath, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
URI umlResourcePluginURI = URI.createURI("jar:file:" + umlResourcePath + "!/");
RESOURCE_SET.getURIConverter().getURIMap().put(URI.createURI(UMLResource.LIBRARIES_PATHMAP),
public org.eclipse.uml2.uml.Package load(URI uri, String pathAbsolute) {
org.eclipse.uml2.uml.Package package_ = null;
if (!"".equals(pathAbsolute))
getResources().getResource(URI.createFileURI(pathAbsolute), true);
try {
Resource resource = getResources().getResource(uri, true);
package_ = (org.eclipse.uml2.uml.Package) EcoreUtil
.getObjectByType(resource.getContents(),
UMLPackage.Literals.PACKAGE);
public class TestUnit{
public void defineSenario("Create a User"){
public void testUnit1(){
assertEquals(1 == 1);
}
}
public void defineSenario("Delete User"){
public void testUnit2(){
protected <T extends Element> void assertContains(List<T> list, String ... expected) {
for (Element t : list) {
String name = t.getName();
if(list.get(0) instanceof mestrado.arquitetura.representation.Package)
for (String str : expected) if(str.equalsIgnoreCase(name)) return ;
if(list.get(0) instanceof mestrado.arquitetura.representation.Class)
for (String str : expected) if(str.equalsIgnoreCase(name)) return ;
}
@Test
public void shouldLoadDependencyClassWithoutPackageAndClassWithPackage() throws Exception{
String uriToArchitecture = getUrlToModel("classPacote");
Architecture architecture = new ArchitectureBuilder().create(uriToArchitecture);
assertNotNull(architecture);
assertEquals(2, architecture.getClasses().size());
assertEquals(1, architecture.getInterClassRelationships().size());
DependencyInterClassRelationship r = (DependencyInterClassRelationship) architecture.getInterClassRelationships().get(0);
public List<GeneralizationInterClassRelationship> getAllGeneralizations(){
List<GeneralizationInterClassRelationship> generalizations = new ArrayList<GeneralizationInterClassRelationship>();
for (InterClassRelationship relation : interClassRelationships)
if (relation instanceof GeneralizationInterClassRelationship)
generalizations.add(((GeneralizationInterClassRelationship)relation));
return generalizations;
}