polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject zest-java git commit: ZEST-143 : Testcase fix. Missing initialization in generated code.
Date Thu, 21 Apr 2016 15:14:52 GMT
Repository: zest-java
Updated Branches:
  refs/heads/develop e7c515042 -> 4b55938a4


ZEST-143 : Testcase fix. Missing initialization in generated code.


Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/4b55938a
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/4b55938a
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/4b55938a

Branch: refs/heads/develop
Commit: 4b55938a469e21ae4b32875955e06e4d9c669689
Parents: e7c5150
Author: Niclas Hedhman <niclas@hedhman.org>
Authored: Thu Apr 21 23:14:16 2016 +0800
Committer: Niclas Hedhman <niclas@hedhman.org>
Committed: Thu Apr 21 23:14:16 2016 +0800

----------------------------------------------------------------------
 .../restlet/crud/EntityListResource.java        | 18 ++++++++---
 .../create/project/AbstractProjectCreator.java  | 34 +++++++++++++-------
 .../project/common/OrderModuleWriter.java       |  1 +
 .../project/restapp/ApplicationWriter.java      |  6 +++-
 .../org/apache/zest/tools/shell/TestHelper.java |  4 +--
 .../tools/shell/create/CreateProjectTest.java   |  3 +-
 6 files changed, 46 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/4b55938a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/crud/EntityListResource.java
----------------------------------------------------------------------
diff --git a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/crud/EntityListResource.java
b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/crud/EntityListResource.java
index 2c2ddec..c969ad4 100644
--- a/libraries/restlet/src/main/java/org/apache/zest/library/restlet/crud/EntityListResource.java
+++ b/libraries/restlet/src/main/java/org/apache/zest/library/restlet/crud/EntityListResource.java
@@ -23,6 +23,7 @@ package org.apache.zest.library.restlet.crud;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 import org.apache.zest.api.entity.Identity;
 import org.apache.zest.api.injection.scope.Service;
@@ -70,7 +71,8 @@ public interface EntityListResource<T extends Identity> extends ServerResource<E
         {
             Property<Request> request = parameters.request();
             Reference base = request.get().getResourceRef();
-            String identity = identityManager.generate( EntityListResource.class, "list["
+ parameters.entityType().get().getSimpleName() +"]" );
+            String name = "list[" + parameters.entityType().get().getSimpleName() + "]";
+            String identity = identityManager.generate( EntityListResource.class, name );
             ValueBuilder<EntityList> builder = vbf.newValueBuilder( EntityList.class
);
             List<EntityRef> result = getEntityRefs( base );
             EntityList prototype = builder.prototype();
@@ -99,14 +101,22 @@ public interface EntityListResource<T extends Identity> extends
ServerResource<E
             return resourceBuilder.createRestLink( name, base, Method.GET );
         }
 
+
+
+
+
+
+
         @SuppressWarnings( "unchecked" )
         private List<EntityRef> getEntityRefs( Reference base )
         {
             ArrayList result = new ArrayList<>();
-            Class<T> entityType = parameters.entityType().get();
+            Property<Class<T>> property = parameters.entityType();
+            Class<T> entityType = property.get();
             CrudRepository<T> repository = locator.find( entityType );
-            StreamSupport
-                .stream( repository.findAll().spliterator(), false )
+            Iterable<T> all = repository.findAll();
+            Stream<T> stream = StreamSupport.stream( all.spliterator(), false );
+            stream
                 .map( entity -> entity.identity().get() )
                 .map( identity -> resourceBuilder.createEntityRef( identity, base ) )
                 .forEach( result::add );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/4b55938a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/AbstractProjectCreator.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/AbstractProjectCreator.java
b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/AbstractProjectCreator.java
index e023be4..e6f49aa 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/AbstractProjectCreator.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/AbstractProjectCreator.java
@@ -41,18 +41,9 @@ abstract class AbstractProjectCreator
     {
         File templateDir = new File( properties.get( "zest.home" ), properties.get( "template.dir"
) );
         copyFiles( templateDir, projectDir, properties.get( "root.package" ) );
-        Path gradlew = new File( projectDir, "gradlew" ).toPath();
-        try
-        {
-            Files.setPosixFilePermissions( gradlew, PosixFilePermissions.fromString( "rwxr-xr-x"
) );
-        }
-        catch( Exception e )
-        {
-            if( ! System.getProperty( "os.name" ).contains( "Windows" ))
-            {
-                throw new IOException( "Unable to set file permissions on " + gradlew.toString(),
e );
-            }
-        }
+        File gradlewFile = new File( projectDir, "gradlew" );
+        Path gradlewPath = gradlewFile.toPath();
+        setGradlewPermissions( gradlewFile, gradlewPath );
     }
 
     private void copyFiles( File fromDir, File toDir, String rootpackage )
@@ -93,4 +84,23 @@ abstract class AbstractProjectCreator
             }
         }
     }
+
+    private void setGradlewPermissions( File gradlewFile, Path gradlewPath )
+        throws IOException
+    {
+        try
+        {
+            if( gradlewFile.exists() )
+            {
+                Files.setPosixFilePermissions( gradlewPath, PosixFilePermissions.fromString(
"rwxr-xr-x" ) );
+            }
+        }
+        catch( Exception e )
+        {
+            if( !System.getProperty( "os.name" ).contains( "Windows" ) )
+            {
+                throw new IOException( "Unable to set file permissions on " + gradlewPath.toString(),
e );
+            }
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/4b55938a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderModuleWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderModuleWriter.java
b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderModuleWriter.java
index aec0d31..0c62bcf 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderModuleWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/common/OrderModuleWriter.java
@@ -61,6 +61,7 @@ public class OrderModuleWriter
                 "    public ModuleAssembly assemble( LayerAssembly layer, ModuleAssembly
module )\n" +
                 "        throws AssemblyException\n" +
                 "    {\n" +
+                "        module.withDefaultUnitOfWorkFactory();\n" +
                 "        module.values( /* add value types */    );\n" +
                 "        module.entities( Customer.class, Order.class, OrderItem.class );\n"
+
                 "        module.services( /* add services */    )\n" +

http://git-wip-us.apache.org/repos/asf/zest-java/blob/4b55938a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ApplicationWriter.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ApplicationWriter.java
b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ApplicationWriter.java
index d66ed94..b1fcb87 100644
--- a/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ApplicationWriter.java
+++ b/tools/shell/src/main/java/org/apache/zest/tools/shell/create/project/restapp/ApplicationWriter.java
@@ -77,7 +77,11 @@ public class ApplicationWriter
             pw.println( "    protected LayeredApplicationAssembler createApplicationAssembler(
String mode )" );
             pw.println( "        throws AssemblyException" );
             pw.println( "    {" );
-            pw.println( format("        return new %sApplicationAssembler( Application.Mode.valueOf(
mode ) );", projectName) );
+            pw.println( "        if( mode != null )" );
+            pw.println( "        {" );
+            pw.println( format("            return new %sApplicationAssembler( Application.Mode.valueOf(
mode ) );", projectName) );
+            pw.println( "        }" );
+            pw.println( format("        return new %sApplicationAssembler( Application.Mode.production
);", projectName) );
             pw.println( "    }" );
             pw.println();
             pw.println( "    @Override" );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/4b55938a/tools/shell/src/test/java/org/apache/zest/tools/shell/TestHelper.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/test/java/org/apache/zest/tools/shell/TestHelper.java b/tools/shell/src/test/java/org/apache/zest/tools/shell/TestHelper.java
index e0389a9..a30109d 100644
--- a/tools/shell/src/test/java/org/apache/zest/tools/shell/TestHelper.java
+++ b/tools/shell/src/test/java/org/apache/zest/tools/shell/TestHelper.java
@@ -29,12 +29,12 @@ public class TestHelper
         String cwd = new File( ".").getAbsolutePath();
         if( cwd.endsWith( "/java/." )) // IDEA default runner
         {
-            String zestHome = new File( new File(".").getAbsoluteFile(), "tools/shell/src"
).getAbsolutePath();
+            String zestHome = new File( new File(".").getAbsoluteFile(), "tools/shell/src/dist"
).getAbsolutePath();
             System.setProperty( "zest.home", zestHome );
         }
         if( cwd.endsWith( "tools/shell/." )) // Gradle build
         {
-            String zestHome = new File( new File(".").getAbsoluteFile(), "src" ).getAbsolutePath();
+            String zestHome = new File( new File(".").getAbsoluteFile(), "src/dist" ).getAbsolutePath();
             System.setProperty( "zest.home", zestHome );
         }
     }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/4b55938a/tools/shell/src/test/java/org/apache/zest/tools/shell/create/CreateProjectTest.java
----------------------------------------------------------------------
diff --git a/tools/shell/src/test/java/org/apache/zest/tools/shell/create/CreateProjectTest.java
b/tools/shell/src/test/java/org/apache/zest/tools/shell/create/CreateProjectTest.java
index 0bc193a..882b19d 100644
--- a/tools/shell/src/test/java/org/apache/zest/tools/shell/create/CreateProjectTest.java
+++ b/tools/shell/src/test/java/org/apache/zest/tools/shell/create/CreateProjectTest.java
@@ -59,7 +59,8 @@ public class CreateProjectTest
         new CreateProject().execute( new String[]{ "create-project", "null", "ZestTest",
"org.apache.zest" }, null, null );
 
         assertThat( dest.exists(), equalTo( true ) );
-        assertThat( new File(dest, "src/main/java/org/apache/zest/package.html").exists(),
equalTo( true ) );
+        File file = new File( dest, "src/main/java/org/apache/zest/package.html" );
+        assertThat( file.exists(), equalTo( true ) );
         if( ! FileUtils.removeDir( dest ) )
         {
             System.err.println( "Unable to remove file. Why???" );


Mime
View raw message