entry : savedHash.entrySet()) {
+ K savedKey = (K) JOhmUtils.Convertor.convert(keyClazz, entry
+ .getKey());
+ V savedValue = JOhm.get(valueClazz, Integer.parseInt(entry
+ .getValue()));
+ backingMap.put(savedKey, savedValue);
+ }
+ }
+ return backingMap;
+ }
+}
+
+```
+
+### Bug Class:
+PROVER
+
+### Kind:
+ERROR
+
+### Bug Type:
+THREAD_SAFETY_VIOLATION
+
+### Qualifier:
+Unprotected write. Non-private method `redis.clients.johm.collections.RedisMap.clear` indirectly writes to field `this.redis.clients.johm.collections.RedisMap.nest.redis.clients.johm.Nest.sb` outside of synchronization.
+ Reporting because another access to the same memory occurs on a background thread, although this access may not.
+
+### Severity:
+HIGH
+
+### Visibility:
+user
+
+### Procedure:
+void RedisMap.clear()
+
+### Procedure Id:
+redis.clients.johm.collections.RedisMap.clear():void.8b6cacc6f959135a3e377dabb35c1d69
+
+### File:
+src/main/java/redis/clients/johm/collections/RedisMap.java
+
+### Key:
+RedisMap.java|clear|THREAD_SAFETY_VIOLATION
+
+### Node Key:
+9c5d6d9028928346cc4fb44cced5dea1
+
+### Hash:
+b88c02118e8a8fc1bb7edd345358764e
+
+### Bug Type Hum:
+Thread Safety Violation
+
+## Task
+
+Fix the bug in the code.
diff --git a/inferredbugs-5773/instruction.md b/inferredbugs-5773/instruction.md
index 0eb59bbe4681d4bfe1b1339b9b1e647672207351..a9c09c29c83b69f61ffb9ece6d28f291978f4708 100644
--- a/inferredbugs-5773/instruction.md
+++ b/inferredbugs-5773/instruction.md
@@ -293,19 +293,4 @@ Thread Safety Violation
## Task
-Analyze the bug information provided above. Your task is to:
-
-1. **Understand the Bug**: Examine the buggy code and identify what the issue was
-2. **Analyze the Root Cause**: Determine why this bug occurred (logic error, edge case, etc.)
-3. **Evaluate the Fix**: Understand how the after code addresses the issue
-4. **Code Review**: Provide insights on code quality, potential improvements, and best practices
-
-### Analysis Questions:
-- What was the specific bug or issue in the original code?
-- What scenarios would trigger this bug?
-- How does the fix address the root cause?
-- Are there any potential edge cases the fix might miss?
-- What coding practices could have prevented this bug?
-- Are there alternative ways to implement the fix?
-
-Use the provided environment to explore, test, or reproduce the bug if needed.
+Fix the bug in the code.
diff --git a/inferredbugs-5786/instruction.md b/inferredbugs-5786/instruction.md
index e39654c59a5cb353bf170c74ad566a973c1f8486..a4d08e4b916795aed14fb771aa7c8f6202029ef5 100644
--- a/inferredbugs-5786/instruction.md
+++ b/inferredbugs-5786/instruction.md
@@ -954,19 +954,4 @@ Thread Safety Violation
## Task
-Analyze the bug information provided above. Your task is to:
-
-1. **Understand the Bug**: Examine the buggy code and identify what the issue was
-2. **Analyze the Root Cause**: Determine why this bug occurred (logic error, edge case, etc.)
-3. **Evaluate the Fix**: Understand how the after code addresses the issue
-4. **Code Review**: Provide insights on code quality, potential improvements, and best practices
-
-### Analysis Questions:
-- What was the specific bug or issue in the original code?
-- What scenarios would trigger this bug?
-- How does the fix address the root cause?
-- Are there any potential edge cases the fix might miss?
-- What coding practices could have prevented this bug?
-- Are there alternative ways to implement the fix?
-
-Use the provided environment to explore, test, or reproduce the bug if needed.
+Fix the bug in the code.
diff --git a/inferredbugs-5918/instruction.md b/inferredbugs-5918/instruction.md
index e4c988993c65bb6959825c3ecc6c7b78e05d8a7a..72000bdb5da5c94e9d5f682be7c47d2911fd5abd 100644
--- a/inferredbugs-5918/instruction.md
+++ b/inferredbugs-5918/instruction.md
@@ -176,19 +176,4 @@ Null Dereference
## Task
-Analyze the bug information provided above. Your task is to:
-
-1. **Understand the Bug**: Examine the buggy code and identify what the issue was
-2. **Analyze the Root Cause**: Determine why this bug occurred (logic error, edge case, etc.)
-3. **Evaluate the Fix**: Understand how the after code addresses the issue
-4. **Code Review**: Provide insights on code quality, potential improvements, and best practices
-
-### Analysis Questions:
-- What was the specific bug or issue in the original code?
-- What scenarios would trigger this bug?
-- How does the fix address the root cause?
-- Are there any potential edge cases the fix might miss?
-- What coding practices could have prevented this bug?
-- Are there alternative ways to implement the fix?
-
-Use the provided environment to explore, test, or reproduce the bug if needed.
+Fix the bug in the code.
diff --git a/inferredbugs-5921/instruction.md b/inferredbugs-5921/instruction.md
index 6829bc34f32d26fcb0651fbcd6de55efeb912f50..fec0e7814adcc8f27877841423ec2ec433674b70 100644
--- a/inferredbugs-5921/instruction.md
+++ b/inferredbugs-5921/instruction.md
@@ -189,19 +189,4 @@ Null Dereference
## Task
-Analyze the bug information provided above. Your task is to:
-
-1. **Understand the Bug**: Examine the buggy code and identify what the issue was
-2. **Analyze the Root Cause**: Determine why this bug occurred (logic error, edge case, etc.)
-3. **Evaluate the Fix**: Understand how the after code addresses the issue
-4. **Code Review**: Provide insights on code quality, potential improvements, and best practices
-
-### Analysis Questions:
-- What was the specific bug or issue in the original code?
-- What scenarios would trigger this bug?
-- How does the fix address the root cause?
-- Are there any potential edge cases the fix might miss?
-- What coding practices could have prevented this bug?
-- Are there alternative ways to implement the fix?
-
-Use the provided environment to explore, test, or reproduce the bug if needed.
+Fix the bug in the code.
diff --git a/inferredbugs-6331/instruction.md b/inferredbugs-6331/instruction.md
index 29a65a5554186d8da254767cf35b474601ae2ddd..fa69f32b4ea3ea61dc2f3aed65a0d6f5cd021516 100644
--- a/inferredbugs-6331/instruction.md
+++ b/inferredbugs-6331/instruction.md
@@ -226,19 +226,4 @@ Resource Leak
## Task
-Analyze the bug information provided above. Your task is to:
-
-1. **Understand the Bug**: Examine the buggy code and identify what the issue was
-2. **Analyze the Root Cause**: Determine why this bug occurred (logic error, edge case, etc.)
-3. **Evaluate the Fix**: Understand how the after code addresses the issue
-4. **Code Review**: Provide insights on code quality, potential improvements, and best practices
-
-### Analysis Questions:
-- What was the specific bug or issue in the original code?
-- What scenarios would trigger this bug?
-- How does the fix address the root cause?
-- Are there any potential edge cases the fix might miss?
-- What coding practices could have prevented this bug?
-- Are there alternative ways to implement the fix?
-
-Use the provided environment to explore, test, or reproduce the bug if needed.
+Fix the bug in the code.
diff --git a/inferredbugs-6338/instruction.md b/inferredbugs-6338/instruction.md
index 7a635e3f6087e02d98c37e37d9a2d88ec4c38659..e131706da5a7cb6f32edb586e6003197813e235b 100644
--- a/inferredbugs-6338/instruction.md
+++ b/inferredbugs-6338/instruction.md
@@ -479,19 +479,4 @@ Thread Safety Violation
## Task
-Analyze the bug information provided above. Your task is to:
-
-1. **Understand the Bug**: Examine the buggy code and identify what the issue was
-2. **Analyze the Root Cause**: Determine why this bug occurred (logic error, edge case, etc.)
-3. **Evaluate the Fix**: Understand how the after code addresses the issue
-4. **Code Review**: Provide insights on code quality, potential improvements, and best practices
-
-### Analysis Questions:
-- What was the specific bug or issue in the original code?
-- What scenarios would trigger this bug?
-- How does the fix address the root cause?
-- Are there any potential edge cases the fix might miss?
-- What coding practices could have prevented this bug?
-- Are there alternative ways to implement the fix?
-
-Use the provided environment to explore, test, or reproduce the bug if needed.
+Fix the bug in the code.
diff --git a/inferredbugs-6755/instruction.md b/inferredbugs-6755/instruction.md
index a959cb07f89828704b46175716e20c6e23770ff9..5f757fd672e49a64bc2a009be63b82fae2061146 100644
--- a/inferredbugs-6755/instruction.md
+++ b/inferredbugs-6755/instruction.md
@@ -481,19 +481,4 @@ Resource Leak
## Task
-Analyze the bug information provided above. Your task is to:
-
-1. **Understand the Bug**: Examine the buggy code and identify what the issue was
-2. **Analyze the Root Cause**: Determine why this bug occurred (logic error, edge case, etc.)
-3. **Evaluate the Fix**: Understand how the after code addresses the issue
-4. **Code Review**: Provide insights on code quality, potential improvements, and best practices
-
-### Analysis Questions:
-- What was the specific bug or issue in the original code?
-- What scenarios would trigger this bug?
-- How does the fix address the root cause?
-- Are there any potential edge cases the fix might miss?
-- What coding practices could have prevented this bug?
-- Are there alternative ways to implement the fix?
-
-Use the provided environment to explore, test, or reproduce the bug if needed.
+Fix the bug in the code.
diff --git a/inferredbugs-6798/instruction.md b/inferredbugs-6798/instruction.md
index 9e6abee32855f76c9cc95da9fbc9396b20b68e88..04f42f5e83bbeba15daa5e19cb6fd542193877e0 100644
--- a/inferredbugs-6798/instruction.md
+++ b/inferredbugs-6798/instruction.md
@@ -511,19 +511,4 @@ Thread Safety Violation
## Task
-Analyze the bug information provided above. Your task is to:
-
-1. **Understand the Bug**: Examine the buggy code and identify what the issue was
-2. **Analyze the Root Cause**: Determine why this bug occurred (logic error, edge case, etc.)
-3. **Evaluate the Fix**: Understand how the after code addresses the issue
-4. **Code Review**: Provide insights on code quality, potential improvements, and best practices
-
-### Analysis Questions:
-- What was the specific bug or issue in the original code?
-- What scenarios would trigger this bug?
-- How does the fix address the root cause?
-- Are there any potential edge cases the fix might miss?
-- What coding practices could have prevented this bug?
-- Are there alternative ways to implement the fix?
-
-Use the provided environment to explore, test, or reproduce the bug if needed.
+Fix the bug in the code.
diff --git a/inferredbugs-6936/instruction.md b/inferredbugs-6936/instruction.md
new file mode 100644
index 0000000000000000000000000000000000000000..e46a057629f5a3f65bd5a4ffb6bf30f1eb47114d
--- /dev/null
+++ b/inferredbugs-6936/instruction.md
@@ -0,0 +1,108 @@
+# InferredBugs Task - Java
+
+## Project Information
+
+**Project:** jboot
+**Bug ID:** 38
+**Language:** java
+
+## Bug Information
+
+### File-Level Changes:
+
+**Before (Buggy File):**
+```java
+/**
+ * Copyright (c) 2015-2018, Michael Yang 杨福海 (fuhai999@gmail.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.jboot.component.shiro.processer;
+
+import com.jfinal.kit.Ret;
+
+/**
+ * 认证处理器 执行后的认证结果。
+ */
+public class AuthorizeResult extends Ret {
+
+ /**
+ * 未进行身份认证
+ */
+ public static final int ERROR_CODE_UNAUTHENTICATED = 1;
+
+ /**
+ * 没有权限访问
+ */
+ public static final int ERROR_CODE_UNAUTHORIZATION = 2;
+
+
+ public static AuthorizeResult ok() {
+ return (AuthorizeResult) new AuthorizeResult().setOk();
+ }
+
+
+ public static AuthorizeResult fail(int errorCode) {
+ return (AuthorizeResult) new AuthorizeResult().setFail().set("errorCode", errorCode);
+ }
+
+ public int getErrorCode() {
+ return (int) get("errorCode");
+ }
+
+}
+
+```
+
+### Bug Class:
+PROVER
+
+### Kind:
+ERROR
+
+### Bug Type:
+NULL_DEREFERENCE
+
+### Qualifier:
+object returned by `get("errorCode")` could be null and is dereferenced at line 46.
+
+### Severity:
+HIGH
+
+### Visibility:
+user
+
+### Procedure:
+int AuthorizeResult.getErrorCode()
+
+### Procedure Id:
+io.jboot.component.shiro.processer.AuthorizeResult.getErrorCode():int.fc420aa421d6f5314b7db4a402e66fcc
+
+### File:
+src/main/java/io/jboot/component/shiro/processer/AuthorizeResult.java
+
+### Key:
+AuthorizeResult.java|getErrorCode|NULL_DEREFERENCE
+
+### Node Key:
+aef15f436bc21a6a19eb4bec819df767
+
+### Hash:
+79e6597aa641ac00b92f8c509558d2cc
+
+### Bug Type Hum:
+Null Dereference
+
+## Task
+
+Fix the bug in the code.
diff --git a/inferredbugs-7024/instruction.md b/inferredbugs-7024/instruction.md
index 4e25e58d25ca44c3e7bf017d61e39f748f5a825b..4a6889a26c0db1245884360be98c14e5d9872efa 100644
--- a/inferredbugs-7024/instruction.md
+++ b/inferredbugs-7024/instruction.md
@@ -501,19 +501,4 @@ Thread Safety Violation
## Task
-Analyze the bug information provided above. Your task is to:
-
-1. **Understand the Bug**: Examine the buggy code and identify what the issue was
-2. **Analyze the Root Cause**: Determine why this bug occurred (logic error, edge case, etc.)
-3. **Evaluate the Fix**: Understand how the after code addresses the issue
-4. **Code Review**: Provide insights on code quality, potential improvements, and best practices
-
-### Analysis Questions:
-- What was the specific bug or issue in the original code?
-- What scenarios would trigger this bug?
-- How does the fix address the root cause?
-- Are there any potential edge cases the fix might miss?
-- What coding practices could have prevented this bug?
-- Are there alternative ways to implement the fix?
-
-Use the provided environment to explore, test, or reproduce the bug if needed.
+Fix the bug in the code.
diff --git a/inferredbugs-7025/instruction.md b/inferredbugs-7025/instruction.md
index 69833947d58b249fb1c0a868dccc7addcfa57e1f..3123d7a0e02ec3e0d750813431d487f6b94695a7 100644
--- a/inferredbugs-7025/instruction.md
+++ b/inferredbugs-7025/instruction.md
@@ -501,19 +501,4 @@ Thread Safety Violation
## Task
-Analyze the bug information provided above. Your task is to:
-
-1. **Understand the Bug**: Examine the buggy code and identify what the issue was
-2. **Analyze the Root Cause**: Determine why this bug occurred (logic error, edge case, etc.)
-3. **Evaluate the Fix**: Understand how the after code addresses the issue
-4. **Code Review**: Provide insights on code quality, potential improvements, and best practices
-
-### Analysis Questions:
-- What was the specific bug or issue in the original code?
-- What scenarios would trigger this bug?
-- How does the fix address the root cause?
-- Are there any potential edge cases the fix might miss?
-- What coding practices could have prevented this bug?
-- Are there alternative ways to implement the fix?
-
-Use the provided environment to explore, test, or reproduce the bug if needed.
+Fix the bug in the code.
diff --git a/inferredbugs-7216/instruction.md b/inferredbugs-7216/instruction.md
new file mode 100644
index 0000000000000000000000000000000000000000..48fd65818ff02a25a4b28c6ff0d7bcba20026b39
--- /dev/null
+++ b/inferredbugs-7216/instruction.md
@@ -0,0 +1,335 @@
+# InferredBugs Task - Java
+
+## Project Information
+
+**Project:** imixs-workflow
+**Bug ID:** 48
+**Language:** java
+
+## Bug Information
+
+### File-Level Changes:
+
+**Before (Buggy File):**
+```java
+package org.imixs.workflow.engine;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import org.imixs.workflow.ItemCollection;
+import org.imixs.workflow.engine.WorkflowSchedulerService;
+import org.imixs.workflow.exceptions.AccessDeniedException;
+import org.imixs.workflow.exceptions.PluginException;
+import org.imixs.workflow.exceptions.ProcessingErrorException;
+import org.junit.Before;
+import org.junit.Test;
+
+import junit.framework.Assert;
+
+/**
+ * Test class for WorkflowSchedulerService
+ *
+ * This test verifies if the inDue methods workItemInDue() and addWorkDays()
+ *
+ * @author rsoika
+ */
+public class TestWorkflowScheduler {
+
+ @Before
+ public void setup() throws PluginException {
+
+ }
+
+ /**
+ * This test the date compare base on $lastProcessingDate in days
+ *
+ * @throws ProcessingErrorException
+ * @throws AccessDeniedException
+ *
+ */
+ @Test
+ public void testDaysOnLastProcess() throws AccessDeniedException, ProcessingErrorException, PluginException {
+
+ ItemCollection doc = new ItemCollection();
+ ItemCollection activity = new ItemCollection();
+
+ // delay unit = days
+ activity.replaceItemValue("keyActivityDelayUnit", "3");
+ // compare type = last process
+ activity.replaceItemValue("keyScheduledBaseObject", "1");
+ // delay
+ activity.replaceItemValue("numActivityDelay", 10);
+
+ Calendar workitemCal = Calendar.getInstance();
+ workitemCal.setTime(new Date());
+ // adjust -14
+ workitemCal.add(Calendar.DAY_OF_MONTH, -14);
+ // prepare doc
+ doc.replaceItemValue("$lastProcessingDate", workitemCal.getTime());
+ Assert.assertTrue(WorkflowSchedulerService.workItemInDue(doc, activity));
+
+ // delay
+ activity.replaceItemValue("numActivityDelay", 15);
+ workitemCal.setTime(new Date());
+ // adjust -14
+ workitemCal.add(Calendar.DAY_OF_MONTH, -14);
+ // prepare doc
+ doc.replaceItemValue("$lastProcessingDate", workitemCal.getTime());
+ Assert.assertFalse(WorkflowSchedulerService.workItemInDue(doc, activity));
+
+ }
+
+
+
+
+ /**
+ * This method tests the addWorkDays function in a weekday movement from
+ * Monday to Fiday
+ */
+ @Test
+ public void testAddWorkdaysFromMonday() {
+
+ Calendar startDate = Calendar.getInstance();
+ // adjust to FRIDAY
+ startDate.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
+ System.out.println("Startdate=" + startDate.getTime());
+
+
+ Assert.assertEquals(Calendar.TUESDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 1).get(Calendar.DAY_OF_WEEK));
+ Assert.assertEquals(Calendar.WEDNESDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 2).get(Calendar.DAY_OF_WEEK));
+ Assert.assertEquals(Calendar.FRIDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 4).get(Calendar.DAY_OF_WEEK));
+
+
+ Assert.assertEquals(Calendar.MONDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 5).get(Calendar.DAY_OF_WEEK));
+
+
+
+
+
+ Assert.assertEquals(Calendar.FRIDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 9).get(Calendar.DAY_OF_WEEK));
+ Assert.assertEquals(Calendar.MONDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 10).get(Calendar.DAY_OF_WEEK));
+
+ }
+
+
+ /**
+ * This method tests the addWorkDays function in a weekday movement from
+ * Friday back to Monday
+ */
+ @Test
+ public void testAddWorkdaysFromFriday() {
+
+ Calendar startDate = Calendar.getInstance();
+ // adjust to FRIDAY
+ startDate.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
+ System.out.println("Startdate=" + startDate.getTime());
+
+ // adjust -3 Workdays -> THUSEDAY
+ Assert.assertEquals(Calendar.TUESDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 2).get(Calendar.DAY_OF_WEEK));
+
+ Assert.assertEquals(Calendar.WEDNESDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 8).get(Calendar.DAY_OF_WEEK));
+
+ Assert.assertEquals(Calendar.FRIDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 10).get(Calendar.DAY_OF_WEEK));
+
+ Assert.assertEquals(Calendar.THURSDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 14).get(Calendar.DAY_OF_WEEK));
+
+ }
+
+ /**
+ * This method tests the addWorkDays function in a weekday movement from
+ * Friday back to Monday
+ */
+ @Test
+ public void testMinusWorkdaysFromFriday() {
+
+ Calendar startDate = Calendar.getInstance();
+ // adjust to FRIDAY
+ startDate.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
+ System.out.println("Startdate=" + startDate.getTime());
+
+ // adjust -3 Workdays -> THUSEDAY
+ Assert.assertEquals(Calendar.THURSDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, -1).get(Calendar.DAY_OF_WEEK));
+ Assert.assertEquals(Calendar.WEDNESDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, -2).get(Calendar.DAY_OF_WEEK));
+ Assert.assertEquals(Calendar.MONDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, -4).get(Calendar.DAY_OF_WEEK));
+ // friday - 5
+ Assert.assertEquals(Calendar.FRIDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, -5).get(Calendar.DAY_OF_WEEK));
+ Assert.assertEquals(Calendar.MONDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, -9).get(Calendar.DAY_OF_WEEK));
+ Assert.assertEquals(Calendar.FRIDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, -10).get(Calendar.DAY_OF_WEEK));
+
+ }
+
+
+ /**
+ * This method tests the addWorkDays function in a weekday movement from
+ * Friday back to Monday
+ */
+ @Test
+ public void testMinusWorkdaysFromMonday() {
+
+ Calendar startDate = Calendar.getInstance();
+ // adjust to FRIDAY
+ startDate.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
+ System.out.println("Startdate=" + startDate.getTime());
+
+ // adjust -3 Workdays -> THUSEDAY
+ Assert.assertEquals(Calendar.THURSDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, -2).get(Calendar.DAY_OF_WEEK));
+
+ }
+
+
+
+ /**
+ * This method tests the addWorkDays function in a weekday movement from
+ * SATURDAY backwards
+ */
+ @Test
+ public void testMinusWorkdaysFromSaturday() {
+
+ Calendar startDate = Calendar.getInstance();
+ // adjust to SATURDAY
+ startDate.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
+ System.out.println("Startdate=" + startDate.getTime());
+
+ // adjust -1 Workdays -> THURSDAY
+ Assert.assertEquals(Calendar.THURSDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, -1).get(Calendar.DAY_OF_WEEK));
+ Assert.assertEquals(Calendar.FRIDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, -5).get(Calendar.DAY_OF_WEEK));
+
+ }
+
+
+ /**
+ * This method tests the addWorkDays function in a weekday movement from
+ * SATURDAY forwards
+ */
+ @Test
+ public void testAddWorkdaysFromSaturday() {
+
+ Calendar startDate = Calendar.getInstance();
+ // adjust to SATURDAY
+ startDate.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
+ System.out.println("Startdate=" + startDate.getTime());
+
+ // adjust -1 Workdays -> TUESDAY
+ Assert.assertEquals(Calendar.TUESDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 1).get(Calendar.DAY_OF_WEEK));
+
+ Assert.assertEquals(Calendar.FRIDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 4).get(Calendar.DAY_OF_WEEK));
+
+
+ Assert.assertEquals(Calendar.MONDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 5).get(Calendar.DAY_OF_WEEK));
+
+ }
+
+ /**
+ * This method tests the addWorkDays function in a weekday movement from
+ * SUNDAY backwards
+ */
+ @Test
+ public void testMinusWorkdaysFromSunday() {
+
+ Calendar startDate = Calendar.getInstance();
+ // adjust to SATURDAY
+ startDate.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
+ System.out.println("Startdate=" + startDate.getTime());
+
+ // adjust -1 Workdays -> THURSDAY
+ Assert.assertEquals(Calendar.THURSDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, -1).get(Calendar.DAY_OF_WEEK));
+ Assert.assertEquals(Calendar.FRIDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, -5).get(Calendar.DAY_OF_WEEK));
+
+ }
+
+ /**
+ * This method tests the addWorkDays function in a weekday movement from
+ * SUNDAY forwards
+ */
+ @Test
+ public void testAddWorkdaysFromSunday() {
+
+ Calendar startDate = Calendar.getInstance();
+ // adjust to SATURDAY
+ startDate.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
+ System.out.println("Startdate=" + startDate.getTime());
+
+ // adjust -1 Workdays -> TUESDAY
+ Assert.assertEquals(Calendar.TUESDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 1).get(Calendar.DAY_OF_WEEK));
+
+ Assert.assertEquals(Calendar.FRIDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 4).get(Calendar.DAY_OF_WEEK));
+
+
+ Assert.assertEquals(Calendar.MONDAY,
+ WorkflowSchedulerService.addWorkDays(startDate, 5).get(Calendar.DAY_OF_WEEK));
+
+ }
+
+}
+
+```
+
+### Bug Class:
+PROVER
+
+### Kind:
+ERROR
+
+### Bug Type:
+NULL_DEREFERENCE
+
+### Qualifier:
+object returned by `addWorkDays(startDate,-1)` could be null and is dereferenced at line 245.
+
+### Severity:
+HIGH
+
+### Visibility:
+user
+
+### Procedure:
+void TestWorkflowScheduler.testMinusWorkdaysFromSunday()
+
+### Procedure Id:
+org.imixs.workflow.engine.TestWorkflowScheduler.testMinusWorkdaysFromSunday():void.33887f6c128d5dabea201891c8b92149
+
+### File:
+imixs-workflow-engine/src/test/java/org/imixs/workflow/engine/TestWorkflowScheduler.java
+
+### Key:
+TestWorkflowScheduler.java|testMinusWorkdaysFromSunday|NULL_DEREFERENCE
+
+### Node Key:
+15891b12c6ce50257e480adc810587ae
+
+### Hash:
+40a7675f67d57f8136ec8e2f7fdde49f
+
+### Bug Type Hum:
+Null Dereference
+
+## Task
+
+Fix the bug in the code.
diff --git a/inferredbugs-7217/instruction.md b/inferredbugs-7217/instruction.md
new file mode 100644
index 0000000000000000000000000000000000000000..67804656d807c8100d34f767d469eaeaf28d8e9b
--- /dev/null
+++ b/inferredbugs-7217/instruction.md
@@ -0,0 +1,1131 @@
+# InferredBugs Task - Java
+
+## Project Information
+
+**Project:** imixs-workflow
+**Bug ID:** 24
+**Language:** java
+
+## Bug Information
+
+### File-Level Changes:
+
+**Before (Buggy File):**
+```java
+package org.imixs.workflow;
+
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.imixs.workflow.xml.XMLDocument;
+import org.imixs.workflow.xml.XMLDocumentAdapter;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+/**
+ * Test class for itemCollection object
+ *
+ * @author rsoika
+ *
+ */
+public class TestItemCollection {
+
+ @Test
+ @Category(org.imixs.workflow.ItemCollection.class)
+ public void testItemCollection() {
+ ItemCollection itemCollection = new ItemCollection();
+ itemCollection.replaceItemValue("txtTitel", "Hello");
+ Assert.assertEquals(itemCollection.getItemValueString("txttitel"), "Hello");
+ }
+
+ @Test
+ @Category(org.imixs.workflow.ItemCollection.class)
+ public void testRemoveItem() {
+ ItemCollection itemCollection = new ItemCollection();
+ itemCollection.replaceItemValue("txtTitel", "Hello");
+ Assert.assertEquals(itemCollection.getItemValueString("txttitel"), "Hello");
+ Assert.assertTrue(itemCollection.hasItem("txtTitel"));
+ itemCollection.removeItem("TXTtitel");
+ Assert.assertFalse(itemCollection.hasItem("txtTitel"));
+ Assert.assertEquals(itemCollection.getItemValueString("txttitel"), "");
+ }
+
+ /**
+ * This test verifies if the method getItemValueDouble returns the expected
+ * values
+ */
+ @Test
+ public void testGetItemValueDouble() {
+ Double d;
+ Long l;
+ Float f;
+ String s;
+ ItemCollection itemCollection = new ItemCollection();
+
+ // test double with digits....
+ d = 1.234;
+ itemCollection.replaceItemValue("double", d);
+ Assert.assertTrue(itemCollection.isItemValueDouble("double"));
+ Assert.assertEquals(1.234, itemCollection.getItemValueDouble("double"), 0);
+
+ // test double with no digits
+ d = (double) 7;
+ itemCollection.replaceItemValue("double", d);
+ Assert.assertEquals(7, itemCollection.getItemValueDouble("double"), 0);
+
+ // test with long value
+ l = (long) 4;
+ itemCollection.replaceItemValue("long", l);
+ Assert.assertEquals(4, itemCollection.getItemValueDouble("long"), 0);
+
+ // test with float value - can not be cast exactly back to double!
+ f = (float) 4.777;
+ itemCollection.replaceItemValue("float", f);
+ Assert.assertFalse(itemCollection.isItemValueDouble("float"));
+
+ // test String....
+ d = 9.712;
+ itemCollection.replaceItemValue("double", d);
+ Assert.assertEquals("9.712", itemCollection.getItemValueString("double"));
+
+ // test cast back from string....
+ s = "9.723";
+ itemCollection.replaceItemValue("string", s);
+ Assert.assertFalse(itemCollection.isItemValueDouble("string"));
+ Assert.assertEquals(9.723, itemCollection.getItemValueDouble("string"), 0);
+
+ }
+
+ /**
+ * This test verifies if the method getItemValueFloat returns the expected
+ * values
+ */
+ @Test
+ public void testGetItemValueFloat() {
+ String s;
+ Float f;
+ ItemCollection itemCollection = new ItemCollection();
+
+ // test with float value
+ f = (float) 4.777;
+ itemCollection.replaceItemValue("float", f);
+ Assert.assertTrue(itemCollection.isItemValueFloat("float"));
+ Float fTest = (float) 4.777;
+ Assert.assertTrue(fTest.equals(itemCollection.getItemValueFloat("float")));
+
+ // test cast back from string....
+ s = "9.723";
+ itemCollection.replaceItemValue("string", s);
+ Assert.assertFalse(itemCollection.isItemValueDouble("string"));
+ // not possible to cast back exactly!
+ // Assert.assertEquals(9.723,
+ // itemCollection.getItemValueFloat("string"),
+ // 0);
+
+ // test Double to Float...
+ double d = 50.777;
+ itemCollection.replaceItemValue("double", d);
+ Assert.assertEquals(d, itemCollection.getItemValueDouble("double"), 0);
+ // test float ...
+ float f1 = itemCollection.getItemValueFloat("double");
+ Assert.assertEquals("50.777", "" + f1);
+
+ }
+
+ /**
+ * This test verifies if the method getItemValueInteger returns the expected
+ * values
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testGetItemValueInteger() {
+ Double d;
+ Long l;
+ Float f;
+ Integer i;
+ Vector v;
+ ItemCollection itemCollection = new ItemCollection();
+
+ // test integer
+ i = 7;
+ itemCollection.replaceItemValue("integer", i);
+ Assert.assertTrue(itemCollection.isItemValueInteger("integer"));
+ Assert.assertEquals(7, itemCollection.getItemValueInteger("integer"), 0);
+
+ // test long
+ l = (long) 8;
+ itemCollection.replaceItemValue("long", l);
+ Assert.assertFalse(itemCollection.isItemValueInteger("long"));
+ Assert.assertTrue(itemCollection.isItemValueLong("long"));
+ Assert.assertEquals(8, itemCollection.getItemValueInteger("long"), 0);
+
+ // test long in vector
+ v = new Vector();
+ l = (long) 8;
+ v.add(l);
+ itemCollection.replaceItemValue("long", v);
+ // should return false...
+ Assert.assertFalse(itemCollection.isItemValueInteger("long"));
+ Assert.assertTrue(itemCollection.isItemValueLong("long"));
+ Assert.assertEquals(8, itemCollection.getItemValueInteger("long"), 0);
+
+ // test double
+ d = 8.765;
+ itemCollection.replaceItemValue("double", d);
+ Assert.assertFalse(itemCollection.isItemValueInteger("double"));
+ Assert.assertTrue(itemCollection.isItemValueDouble("double"));
+ Assert.assertEquals(8, itemCollection.getItemValueInteger("double"), 0);
+
+ // test float
+ f = (float) 8.765;
+ itemCollection.replaceItemValue("float", f);
+ Assert.assertFalse(itemCollection.isItemValueInteger("float"));
+ Assert.assertTrue(itemCollection.isItemValueFloat("float"));
+ Assert.assertEquals(8, itemCollection.getItemValueInteger("float"), 0);
+
+ }
+
+ /**
+ * This test verifies the equals method for a ItemCollection
+ */
+ @Test
+ public void testEquals() {
+
+ ItemCollection itemCollection1 = new ItemCollection();
+ ItemCollection itemCollection2 = new ItemCollection();
+
+ itemCollection1.replaceItemValue("txtName", "Manfred");
+ itemCollection2.replaceItemValue("txtname", "Manfred");
+ itemCollection1.replaceItemValue("numID", new Integer(20));
+ itemCollection2.replaceItemValue("numID", new Integer(20));
+
+ Assert.assertEquals(itemCollection1, itemCollection2);
+ Assert.assertNotSame(itemCollection1, itemCollection2);
+
+ // compare not equals
+ itemCollection1.replaceItemValue("txtName", "Manfred");
+ itemCollection2.replaceItemValue("txtname", "Manfred1");
+
+ Assert.assertFalse(itemCollection1.equals(itemCollection2));
+ itemCollection2.replaceItemValue("txtname", "Manfred");
+ itemCollection2.replaceItemValue("numID", new Integer(21));
+ Assert.assertFalse(itemCollection1.equals(itemCollection2));
+ Assert.assertNotSame(itemCollection1, itemCollection2);
+
+ }
+
+ /**
+ * This test verifies the behavior when copy the elements of another
+ * ItemCollection
+ *
+ */
+ @Test
+ public void testCopyValues() {
+
+ ItemCollection itemCollection1 = new ItemCollection();
+ ItemCollection itemCollection2 = new ItemCollection();
+
+ itemCollection1.replaceItemValue("txtName", "Manfred");
+ itemCollection1.replaceItemValue("numID", new Integer(20));
+
+ // copy values
+ itemCollection2.replaceAllItems(itemCollection1.getAllItems());
+ Assert.assertEquals(itemCollection1, itemCollection2);
+ Assert.assertNotSame(itemCollection1, itemCollection2);
+
+ // change value of itemcol2
+ itemCollection2.replaceItemValue("txtName", "Anna");
+ Assert.assertEquals("Manfred", itemCollection1.getItemValueString("txtName"));
+ Assert.assertEquals("Anna", itemCollection2.getItemValueString("txtName"));
+
+ Assert.assertFalse(itemCollection1.equals(itemCollection2));
+ Assert.assertNotSame(itemCollection1, itemCollection2);
+
+ }
+
+ /**
+ * This test verifies the behavior when copy the elements of another
+ * ItemCollection with embedded collections!
+ *
+ */
+ @Test
+ public void testCopyItemCollection() {
+
+ ItemCollection itemCollection1 = new ItemCollection();
+ itemCollection1.replaceItemValue("txtName", "Manfred");
+ itemCollection1.replaceItemValue("numID", new Integer(20));
+
+ ItemCollection itemCollection2 = new ItemCollection(itemCollection1);
+
+ Assert.assertEquals(itemCollection1, itemCollection2);
+ Assert.assertNotSame(itemCollection1, itemCollection2);
+
+ // change valud of itemcol2
+ itemCollection2.replaceItemValue("txtName", "Anna");
+ Assert.assertEquals("Manfred", itemCollection1.getItemValueString("txtName"));
+ Assert.assertEquals("Anna", itemCollection2.getItemValueString("txtName"));
+
+ }
+
+ /**
+ * This test verifies the behavior when copy the elements of another
+ * ItemCollection with embedded collections!
+ *
+ */
+ @SuppressWarnings("unused")
+ @Test
+ public void testCopyValuesWithEmbeddedCollection() {
+
+ ItemCollection itemCollection1 = new ItemCollection();
+ ItemCollection itemCollection2 = new ItemCollection();
+ ItemCollection child1 = new ItemCollection();
+
+ itemCollection1.replaceItemValue("txtName", "Manfred");
+ itemCollection1.replaceItemValue("numID", new Integer(20));
+
+ child1.replaceItemValue("txtName", "Thor");
+ child1.replaceItemValue("numID", new Integer(2));
+
+ try {
+ itemCollection1.replaceItemValue("child", XMLDocumentAdapter.getDocument(child1));
+ } catch (Exception e) {
+
+ Assert.fail();
+ }
+
+ // copy values
+ itemCollection2.replaceAllItems(itemCollection1.getAllItems());
+ Assert.assertEquals(itemCollection1, itemCollection2);
+
+ Assert.assertNotSame(itemCollection1, itemCollection2);
+
+ XMLDocument xmlChild = (XMLDocument) itemCollection1.getItemValue("child").get(0);
+
+ ItemCollection testChild = XMLDocumentAdapter.putDocument(xmlChild);
+ Assert.assertEquals(2, testChild.getItemValueInteger("numID"));
+
+ // manipulate child1 and repeat the test!
+ child1.replaceItemValue("numID", new Integer(3));
+ Assert.assertEquals(itemCollection1, itemCollection2);
+ Assert.assertNotSame(itemCollection1, itemCollection2);
+
+ // Now its the same object !
+ Assert.assertNotSame(child1, testChild);
+
+ // test child1 form itemcol1
+ xmlChild = (XMLDocument) itemCollection1.getItemValue("child").get(0);
+
+ testChild = XMLDocumentAdapter.putDocument(xmlChild);
+
+ // expected id is not 3!
+ Assert.assertEquals(2, testChild.getItemValueInteger("numID"));
+
+ // change value of itemcol2
+ itemCollection2.replaceItemValue("txtName", "Anna");
+ Assert.assertEquals("Manfred", itemCollection1.getItemValueString("txtName"));
+ Assert.assertEquals("Anna", itemCollection2.getItemValueString("txtName"));
+
+ Assert.assertFalse(itemCollection1.equals(itemCollection2));
+ Assert.assertNotSame(itemCollection1, itemCollection2);
+
+ }
+
+ /**
+ * Same as testCopyValuesWithEmbeddedCollection but now we add a list of
+ * ItemCollections into a ItemCollection!
+ *
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testCopyValuesWithEmbeddedCollectionList() {
+
+ ItemCollection itemCollection1 = new ItemCollection();
+ ItemCollection itemCollection2 = new ItemCollection();
+ ItemCollection child1 = new ItemCollection();
+ ItemCollection child2 = new ItemCollection();
+
+ itemCollection1.replaceItemValue("txtName", "Manfred");
+ itemCollection1.replaceItemValue("numID", new Integer(20));
+
+ child1.replaceItemValue("txtName", "Thor");
+ child1.replaceItemValue("numID", new Integer(2));
+ child2.replaceItemValue("txtName", "Ilias");
+ child2.replaceItemValue("numID", new Integer(3));
+ List childs = new ArrayList<>();
+ try {
+ childs.add(XMLDocumentAdapter.getDocument(child1));
+ childs.add(XMLDocumentAdapter.getDocument(child2));
+ } catch (Exception e) {
+ e.printStackTrace();
+ Assert.fail();
+ }
+ itemCollection1.replaceItemValue("childs", childs);
+
+ // copy values
+ itemCollection2.replaceAllItems(itemCollection1.getAllItems());
+ Assert.assertEquals(itemCollection1, itemCollection2);
+ Assert.assertNotSame(itemCollection1, itemCollection2);
+
+ // now manipulate child1
+ child1.replaceItemValue("numID", 101);
+
+ // repeat test!
+ Assert.assertEquals(itemCollection1, itemCollection2);
+ Assert.assertNotSame(itemCollection1, itemCollection2);
+
+ // get child 1 from itemcol2
+ List v = itemCollection2.getItemValue("childs");
+ XMLDocument xmlct1 = (XMLDocument) v.get(0);
+ ItemCollection ct1 = XMLDocumentAdapter.putDocument(xmlct1);
+ Assert.assertEquals("Thor", ct1.getItemValueString("txtName"));
+ Assert.assertEquals(2, ct1.getItemValueInteger("numID"));
+
+ Assert.assertEquals(101, child1.getItemValueInteger("numID"));
+
+ XMLDocument xmlct2 = (XMLDocument) v.get(1);
+ ItemCollection ct2 = XMLDocumentAdapter.putDocument(xmlct2);
+ Assert.assertEquals("Ilias", ct2.getItemValueString("txtName"));
+ Assert.assertEquals(3, ct2.getItemValueInteger("numID"));
+
+ // test size
+ Assert.assertTrue(v.size() == 2);
+
+ }
+
+ /**
+ * Same as testCopyValuesWithEmbeddedCollection but now we test the behavior
+ * with map interfaces
+ *
+ * here we can see that a map is copied by reference!
+ *
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Test
+ public void testCopyValuesWithEmbeddedMap() {
+
+ ItemCollection itemCollection1 = new ItemCollection();
+ ItemCollection itemCollection2 = new ItemCollection();
+ Map child1 = new HashMap();
+
+ itemCollection1.replaceItemValue("txtName", "Manfred");
+ itemCollection1.replaceItemValue("numID", new Integer(20));
+
+ child1.put("txtName", "Thor");
+ child1.put("numID", new Integer(2));
+
+ itemCollection1.replaceItemValue("child", child1);
+
+ // copy values
+ itemCollection2.replaceAllItems(itemCollection1.getAllItems());
+ Assert.assertEquals(itemCollection1, itemCollection2);
+ Assert.assertNotSame(itemCollection1, itemCollection2);
+ Map testChild = (Map) itemCollection1.getItemValue("child").get(0);
+ Assert.assertEquals(2, testChild.get("numID"));
+
+ // manipulate child1 and repeat the test!
+ child1.put("numID", new Integer(3));
+ Assert.assertFalse(itemCollection1.equals(itemCollection2));
+ Assert.assertNotSame(itemCollection1, itemCollection2);
+
+ // its the same object !
+ Assert.assertSame(child1, testChild);
+
+ }
+
+ /**
+ * This test verifies the imixs workflow basic attributes
+ *
+ */
+ @Test
+ public void testBasicAttributes() {
+
+ ItemCollection itemCollection1 = new ItemCollection();
+
+ itemCollection1.replaceItemValue(WorkflowKernel.MODELVERSION, "1.0.0");
+ itemCollection1.replaceItemValue(WorkflowKernel.TASKID, 100);
+ itemCollection1.replaceItemValue(WorkflowKernel.EVENTID, 10);
+ itemCollection1.replaceItemValue(WorkflowKernel.TYPE, "workitem_test");
+ itemCollection1.replaceItemValue(WorkflowKernel.UNIQUEID, "ABC-123");
+
+ Assert.assertEquals("1.0.0", itemCollection1.getModelVersion());
+ Assert.assertEquals(10, itemCollection1.getEventID());
+ Assert.assertEquals(100, itemCollection1.getTaskID());
+ Assert.assertEquals("workitem_test", itemCollection1.getType());
+ Assert.assertEquals("ABC-123", itemCollection1.getUniqueID());
+
+ }
+
+ /**
+ * This method verifies if null values will be removed from lists.
+ */
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ @Test
+ public void testNullValues() {
+
+ Vector v1 = new Vector();
+ v1.add(null);
+ v1.add("");
+ v1.add(null);
+ v1.add("anna");
+
+ Vector v2 = new Vector();
+ v1.add(null);
+
+ ItemCollection itemCol = new ItemCollection();
+ itemCol.replaceItemValue("a", v1);
+ itemCol.replaceItemValue("b", v2);
+
+ List l1 = itemCol.getItemValue("a");
+ List l2 = itemCol.getItemValue("b");
+
+ // test if the null values are removed...
+ Assert.assertEquals(2, l1.size());
+ Assert.assertEquals("", l1.get(0));
+ Assert.assertEquals("anna", l1.get(1));
+
+ Assert.assertEquals(0, l2.size());
+
+ }
+
+ @Test
+ @Category(org.imixs.workflow.ItemCollection.class)
+ public void testItemCollectionItemNameList() {
+ ItemCollection itemCollection = new ItemCollection();
+ itemCollection.replaceItemValue("_subject", "Hello");
+ itemCollection.replaceItemValue("_dummy", "Hello");
+ itemCollection.replaceItemValue("_title", "Hello");
+
+ List itemNames = itemCollection.getItemNames();
+ Assert.assertEquals(3, itemNames.size());
+
+ itemCollection.removeItem("_dummy");
+ itemNames = itemCollection.getItemNames();
+ Assert.assertEquals(2, itemNames.size());
+
+ }
+
+ /**
+ * This method verifies the clone interface
+ */
+ @Test
+ public void testCloning() {
+
+ ItemCollection itemCol1 = new ItemCollection();
+ itemCol1.replaceItemValue("a", 1);
+ itemCol1.replaceItemValue("b", "hello");
+ itemCol1.replaceItemValue("c", "world");
+
+ // clone only some attributes
+ List attributes = new ArrayList();
+ attributes.add("a");
+ attributes.add("b");
+ ItemCollection itemCol2 = itemCol1.clone(attributes);
+
+ Assert.assertNotNull(itemCol2);
+
+ // test values of clone
+ Assert.assertEquals(1, itemCol2.getItemValueInteger("a"));
+ Assert.assertEquals("hello", itemCol2.getItemValueString("b"));
+ Assert.assertEquals("", itemCol2.getItemValueString("c"));
+
+ // test full clone
+ ItemCollection itemCol3 = null;
+
+ if (itemCol1 instanceof Cloneable) {
+ itemCol3 = (ItemCollection) itemCol1.clone();
+ }
+ Assert.assertNotNull(itemCol3);
+ Assert.assertEquals(1, itemCol3.getItemValueInteger("a"));
+ Assert.assertEquals("hello", itemCol3.getItemValueString("b"));
+ Assert.assertEquals("world", itemCol3.getItemValueString("c"));
+
+ // itemCol2 should be equals to itemCol1
+ Assert.assertNotSame(itemCol2, itemCol1);
+ // itemCol3 should be equals to itemCol1
+ Assert.assertNotSame(itemCol3, itemCol1);
+ // itemCol3 should be equals to itemCol1
+ Assert.assertEquals(itemCol1, itemCol3);
+ // itemCol2 should be equals to itemCol1
+ Assert.assertFalse(itemCol1.equals(itemCol2));
+
+ // now we change some values of itemCol1 to see if this affects itemCol2
+ // and itemCol3....
+ itemCol1.replaceItemValue("c", "Imixs");
+ Assert.assertEquals("", itemCol2.getItemValueString("c"));
+ Assert.assertEquals("world", itemCol3.getItemValueString("c"));
+
+ }
+
+ /**
+ * This method verifies the clone interface in conjunction with byte arrays as
+ * used in the $file field
+ */
+ @Test
+ public void testCloningByteArrays() {
+
+ ItemCollection itemCol1 = new ItemCollection();
+ itemCol1.replaceItemValue("a", 1);
+ itemCol1.replaceItemValue("b", "hello");
+ itemCol1.replaceItemValue("c", "world");
+ byte[] empty = { 0 };
+ // add a dummy file
+ itemCol1.addFile(empty, "test1.txt", "application/xml");
+
+ ItemCollection itemCol2 = (ItemCollection) itemCol1.clone();
+
+ Assert.assertNotNull(itemCol2);
+
+ // test values of clone
+ Assert.assertEquals(1, itemCol2.getItemValueInteger("a"));
+ Assert.assertEquals("hello", itemCol2.getItemValueString("b"));
+ // test the byte content of itemcol2
+ Map> conedFilesTest = itemCol2.getFiles();
+ List