You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2018/03/16 16:01:05 UTC

[isis] branch master updated (347a4d2 -> 5eecb94)

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git.


    from 347a4d2  ISIS-1904 add build badge to front-page (github)
     new ca24c1f  ISIS-1925: adds a null guard in CommonDtoUtils for blob and clob's
     new 4c080a3  Merge branch 'ISIS-1925' into maint-1.16.2
     new 5eecb94  Merge branch 'maint-1.16.2'

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitignore                                         |  1 +
 .../apache/isis/schema/utils/CommonDtoUtils.java   | 30 +++------
 .../utils/CommonDtoUtils_setValueOn_Test.java      | 71 ++++++++++++++++++++++
 3 files changed, 81 insertions(+), 21 deletions(-)
 create mode 100644 core/applib/src/test/java/org/apache/isis/schema/utils/CommonDtoUtils_setValueOn_Test.java

-- 
To stop receiving notification emails like this one, please contact
danhaywood@apache.org.

[isis] 01/03: ISIS-1925: adds a null guard in CommonDtoUtils for blob and clob's

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit ca24c1f9d15da86143666c88fa3cf4b5178274b0
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Fri Mar 16 15:44:48 2018 +0000

    ISIS-1925: adds a null guard in CommonDtoUtils for blob and clob's
---
 .gitignore                                         |  2 +
 .../apache/isis/schema/utils/CommonDtoUtils.java   | 24 +++++---
 .../utils/CommonDtoUtils_setValueOn_Test.java      | 71 ++++++++++++++++++++++
 3 files changed, 87 insertions(+), 10 deletions(-)

diff --git a/.gitignore b/.gitignore
index 83896b3..4d7509d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -45,3 +45,5 @@ core/integtestsupport/fixture-data
 
 rebel.xml
 **/.DS_Store
+
+.flattened-pom.xml
diff --git a/core/applib/src/main/java/org/apache/isis/schema/utils/CommonDtoUtils.java b/core/applib/src/main/java/org/apache/isis/schema/utils/CommonDtoUtils.java
index 6c3ea91..605c886 100644
--- a/core/applib/src/main/java/org/apache/isis/schema/utils/CommonDtoUtils.java
+++ b/core/applib/src/main/java/org/apache/isis/schema/utils/CommonDtoUtils.java
@@ -263,20 +263,24 @@ public final class CommonDtoUtils {
         }
         case BLOB: {
             final Blob blob = (Blob) val;
-            final BlobDto blobDto = new BlobDto();
-            blobDto.setName(blob.getName());
-            blobDto.setBytes(blob.getBytes());
-            blobDto.setMimeType(blob.getMimeType().toString());
-            valueDto.setBlob(blobDto);
+            if(blob != null) {
+                final BlobDto blobDto = new BlobDto();
+                blobDto.setName(blob.getName());
+                blobDto.setBytes(blob.getBytes());
+                blobDto.setMimeType(blob.getMimeType().toString());
+                valueDto.setBlob(blobDto);
+            }
             return valueDto;
         }
         case CLOB: {
             final Clob clob = (Clob) val;
-            final ClobDto clobDto = new ClobDto();
-            clobDto.setName(clob.getName());
-            clobDto.setChars(clob.getChars().toString());
-            clobDto.setMimeType(clob.getMimeType().toString());
-            valueDto.setClob(clobDto);
+            if(clob != null) {
+                final ClobDto clobDto = new ClobDto();
+                clobDto.setName(clob.getName());
+                clobDto.setChars(clob.getChars().toString());
+                clobDto.setMimeType(clob.getMimeType().toString());
+                valueDto.setClob(clobDto);
+            }
             return valueDto;
         }
         case VOID: {
diff --git a/core/applib/src/test/java/org/apache/isis/schema/utils/CommonDtoUtils_setValueOn_Test.java b/core/applib/src/test/java/org/apache/isis/schema/utils/CommonDtoUtils_setValueOn_Test.java
new file mode 100644
index 0000000..ee4f275
--- /dev/null
+++ b/core/applib/src/test/java/org/apache/isis/schema/utils/CommonDtoUtils_setValueOn_Test.java
@@ -0,0 +1,71 @@
+package org.apache.isis.schema.utils;
+
+import org.jmock.auto.Mock;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.isis.applib.services.bookmark.BookmarkService;
+import org.apache.isis.applib.value.Blob;
+import org.apache.isis.applib.value.Clob;
+import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
+import org.apache.isis.schema.common.v1.BlobDto;
+import org.apache.isis.schema.common.v1.ClobDto;
+import org.apache.isis.schema.common.v1.ValueDto;
+import org.apache.isis.schema.common.v1.ValueType;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+
+public class CommonDtoUtils_setValueOn_Test {
+
+    @Rule
+    public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(JUnitRuleMockery2.Mode.INTERFACES_AND_CLASSES);
+
+    @Mock
+    private BookmarkService mockBookmarkService;
+
+    ValueDto valueDto;
+    @Before
+    public void setUp() throws Exception {
+        valueDto = new ValueDto();
+    }
+
+    @Test
+    public void when_blob_is_null() {
+        CommonDtoUtils.setValueOn(valueDto, ValueType.BLOB, null, mockBookmarkService);
+        final BlobDto blobDto = valueDto.getBlob();
+        Assert.assertThat(blobDto, is(nullValue()));
+    }
+
+    @Test
+    public void when_blob_is_not_null() {
+        final Blob val = new Blob("image.png", "image/png", new byte[]{1,2,3,4,5});
+        CommonDtoUtils.setValueOn(valueDto, ValueType.BLOB, val, mockBookmarkService);
+        final BlobDto blobDto = valueDto.getBlob();
+        Assert.assertThat(blobDto, is(notNullValue()));
+        Assert.assertThat(blobDto.getBytes(), is(val.getBytes()));
+        Assert.assertThat(blobDto.getName(), is(val.getName()));
+        Assert.assertThat(blobDto.getMimeType(), is(val.getMimeType().toString()));
+    }
+
+    @Test
+    public void when_clob_is_null() {
+        CommonDtoUtils.setValueOn(valueDto, ValueType.CLOB, null, mockBookmarkService);
+        final ClobDto clobDto = valueDto.getClob();
+        Assert.assertThat(clobDto, is(nullValue()));
+    }
+
+    @Test
+    public void when_clob_is_not_null() {
+        final Clob val = new Clob("image.png", "image/png", new char[]{1,2,3,4,5});
+        CommonDtoUtils.setValueOn(valueDto, ValueType.CLOB, val, mockBookmarkService);
+        final ClobDto clobDto = valueDto.getClob();
+        Assert.assertThat(clobDto, is(notNullValue()));
+        Assert.assertThat(clobDto.getChars(), is(val.getChars()));
+        Assert.assertThat(clobDto.getName(), is(val.getName()));
+        Assert.assertThat(clobDto.getMimeType(), is(val.getMimeType().toString()));
+    }
+}
\ No newline at end of file

-- 
To stop receiving notification emails like this one, please contact
danhaywood@apache.org.

[isis] 03/03: Merge branch 'maint-1.16.2'

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 5eecb9419bb17a1913cfa8ea0add9420bf1d3387
Merge: 347a4d2 4c080a3
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Fri Mar 16 16:00:21 2018 +0000

    Merge branch 'maint-1.16.2'

 .gitignore                                         |  1 +
 .../apache/isis/schema/utils/CommonDtoUtils.java   | 30 +++------
 .../utils/CommonDtoUtils_setValueOn_Test.java      | 71 ++++++++++++++++++++++
 3 files changed, 81 insertions(+), 21 deletions(-)

diff --cc core/applib/src/main/java/org/apache/isis/schema/utils/CommonDtoUtils.java
index de9a2d6,605c886..252a1f7
--- a/core/applib/src/main/java/org/apache/isis/schema/utils/CommonDtoUtils.java
+++ b/core/applib/src/main/java/org/apache/isis/schema/utils/CommonDtoUtils.java
@@@ -256,21 -262,14 +256,15 @@@ public final class CommonDtoUtils 
              return valueDto;
          }
          case BLOB: {
 +        	
              final Blob blob = (Blob) val;
-             final BlobDto blobDto = new BlobDto();
-             
-             if(blob==null) {
-                 blobDto.setName("#empty");
-                 blobDto.setBytes(new byte[0]);
-                 blobDto.setMimeType("");	
-         	} else {
+             if(blob != null) {
+                 final BlobDto blobDto = new BlobDto();
                  blobDto.setName(blob.getName());
                  blobDto.setBytes(blob.getBytes());
-                 blobDto.setMimeType(blob.getMimeType().toString());	
-         	}
-             
-             valueDto.setBlob(blobDto);
+                 blobDto.setMimeType(blob.getMimeType().toString());
+                 valueDto.setBlob(blobDto);
+             }
              return valueDto;
          }
          case CLOB: {

-- 
To stop receiving notification emails like this one, please contact
danhaywood@apache.org.

[isis] 02/03: Merge branch 'ISIS-1925' into maint-1.16.2

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 4c080a35be516250583869f0215332e70bfab610
Merge: 529112d ca24c1f
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Fri Mar 16 15:58:29 2018 +0000

    Merge branch 'ISIS-1925' into maint-1.16.2
    
    # Conflicts:
    #	.gitignore

 .gitignore                                         |  1 +
 .../apache/isis/schema/utils/CommonDtoUtils.java   | 24 +++++---
 .../utils/CommonDtoUtils_setValueOn_Test.java      | 71 ++++++++++++++++++++++
 3 files changed, 86 insertions(+), 10 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
danhaywood@apache.org.