commit de8ed2a264445bb092460483f81a5bbc36a06610
Author: Jan Jirman <fajirmja@seznam.cz>
Date:   Thu May 9 10:56:47 2019 +0200

    Testovací třída testBitmap... objevena chyba v generování pozice bitmapy - opraveno (Re #7443)

diff --git a/src/data/Bitmap.java b/src/data/Bitmap.java
index 0bb61cf..985edff 100644
--- a/src/data/Bitmap.java
+++ b/src/data/Bitmap.java
@@ -81,7 +81,8 @@ public class Bitmap {
         LocalDate to = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
 
         long datePosition = ChronoUnit.DAYS.between(from, to);
-        return datePosition+1;
+        //Re #7443
+        return datePosition;
     }
 
 
@@ -301,6 +302,11 @@ public class Bitmap {
         bitmap.setWorkdays(1);
         System.out.println("\nJede v pracovní dny:");
         System.out.println(bitmap.toString());
+        
+        bitmap.fillWithZeros();
+        
+        bitmap.setSundaysAndHolidays(1);
+        System.out.println(bitmap.toString());
 
         // Kontrola přemazání
         System.out.println("\nKontrola přemazání:");
@@ -314,6 +320,11 @@ public class Bitmap {
 
         //přemazání
         bitmap.fillWithZeros();
+        
+        Calendar dateTo2 = Calendar.getInstance();
+        dateTo2.setTime(new Date(2019-1900, 4, 13));
+        bitmap.setWeeksRange(dateFrom, dateTo2, 1, 1);
+        System.out.println(bitmap.toString());
 
         //Nastavit liché týdny (zbytek(remainder) 1 - liché)
         System.out.println("\nLiché týdny:");
diff --git a/src/test/testBitmap.java b/src/test/testBitmap.java
new file mode 100644
index 0000000..245b6f1
--- /dev/null
+++ b/src/test/testBitmap.java
@@ -0,0 +1,227 @@
+package test;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import data.Bitmap;
+import data.DataReader;
+
+public class testBitmap {
+	private static final Logger log = Logger.getLogger(testJDFCaskodyRecord.class);
+    private static Bitmap bitmap;
+    private static Calendar dateFrom = Calendar.getInstance();
+    private static Calendar dateTo = Calendar.getInstance();
+
+    @BeforeClass
+    public static void setUpBeforeClass() {
+
+        BasicConfigurator.configure();
+        Logger.getRootLogger().setLevel(Level.INFO);
+    
+    }
+    
+    @Before
+    public void setUpBefore() {
+               
+        dateFrom.setTime(new Date(2019-1900, 4, 1)); // -- Jen pro testování Deprecated --
+        dateTo.setTime(new Date(2019-1900, 4, 31)); // rok udáván od 1900, měsíc se počítá od 0
+
+
+        bitmap = new Bitmap(dateFrom, dateTo, "143440", "1");
+    
+    }
+
+ 
+    @Test
+    public void testgetDateRange(){
+       assertEquals(31,bitmap.getDateRange());
+    }
+    
+    @Test
+    public void testsetDay() {
+    	Calendar date = Calendar.getInstance();
+    	date.setTime(new Date(2019-1900, 4, 3));
+    	bitmap.setDay(date, 1);
+    	date.setTime(new Date(2019-1900, 4, 4));
+    	bitmap.setDay(date, 1);
+    	assertEquals(0,bitmap.toString().compareToIgnoreCase("[0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"));
+    }
+    
+    @Test
+    public void testgetDatePosition() {
+    	Calendar date = Calendar.getInstance();
+    	date.setTime(new Date(2019-1900, 4, 3));
+    	long position = bitmap.getDatePosition(date);
+    	assertEquals(2,position);
+    	
+    }
+    
+    @Test
+    public void testsetWorkdays() {
+    	bitmap.setWorkdays(1);
+    	assertEquals(0,bitmap.toString().compareToIgnoreCase("[1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1]"));
+    }
+    
+    @Test
+    public void testsetSundaysAndHolidays() {
+    	bitmap.setSundaysAndHolidays(1);
+    	assertEquals(0,bitmap.toString().compareToIgnoreCase("[1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]"));
+    }
+    
+    
+    @Test
+    public void testsetOneDayOnly() {
+    	Calendar date = Calendar.getInstance();
+    	date.setTime(new Date(2019-1900, 4, 3));
+    	bitmap.setOneDayOnly(date);
+    	assertEquals(0,bitmap.toString().compareToIgnoreCase("[0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"));
+   
+    }
+    
+    @Test
+    public void testsetDaysInRange() {
+    	Calendar date1 = Calendar.getInstance();
+    	date1.setTime(new Date(2019-1900, 4, 3));
+    	Calendar date2 = Calendar.getInstance();
+    	date2.setTime(new Date(2019-1900, 4, 5));
+    	bitmap.setDaysInRange(date1,date2, 1);
+    	//Kromě 5.4. - má být dobře?
+    	assertEquals(0,bitmap.toString().compareToIgnoreCase("[0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"));
+    }
+    
+    @Test
+    public void testsetDaysInWeek(){
+    	bitmap.setDaysInWeek(2, 1); //kazde pondeli ... pondeli - 2
+    	assertEquals(0,bitmap.toString().compareToIgnoreCase("[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]"));
+    	
+    }
+    
+    @Test
+    public void testsetWeeks(){
+    	bitmap.setWeeks(1, 1);
+    	assertEquals(0,bitmap.toString().compareToIgnoreCase("[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]"));
+    	
+    }
+    
+    @Test
+    public void testsetWeeksRange(){
+    	Calendar date1 = Calendar.getInstance();
+    	date1.setTime(new Date(2019-1900, 4, 1));
+    	Calendar date2 = Calendar.getInstance();
+    	date2.setTime(new Date(2019-1900, 4, 13));
+    	bitmap.setWeeksRange(date1,date2, 1, 1);
+    	assertEquals(0,bitmap.toString().compareToIgnoreCase("[1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"));
+    
+    }
+    
+    @Test
+    public void testfillWithZeros(){
+    	bitmap.fillWithZeros();
+    	assertEquals(0,bitmap.toString().compareToIgnoreCase("[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"));
+    	
+    }
+    
+    @Test
+    public void testvalidateValue(){
+    	int value = -1;
+    	int exceptedZero = Bitmap.validateValue(value);
+    	assertEquals(0,exceptedZero);
+    	value = 0;
+    	exceptedZero = Bitmap.validateValue(value);
+    	assertEquals(0,exceptedZero);
+    	value = 1;
+    	int exceptedOne = Bitmap.validateValue(value);
+    	assertEquals(1,exceptedOne);
+    	value = 2;
+    	exceptedOne = Bitmap.validateValue(value);
+    	assertEquals(1,exceptedOne);   	
+    }
+    
+    @Test
+    public void testgetDateFrom(){
+    	assertEquals(0,bitmap.getDateFrom().getTime().toString().compareToIgnoreCase("Wed May 01 00:00:00 CEST 2019"));   	
+    }
+    
+    @Test
+    public void testsetDateFrom(){
+    	dateFrom.setTime(new Date(2019-1900, 4, 2));
+    	assertEquals(0,bitmap.getDateFrom().getTime().toString().compareToIgnoreCase("Thu May 02 00:00:00 CEST 2019"));   
+    }
+    
+    @Test
+    public void testgetDateTo() {
+    	assertEquals(0,bitmap.getDateTo().getTime().toString().compareToIgnoreCase("Fri May 31 00:00:00 CEST 2019")); 
+    }
+
+    @Test
+    public void testsetDateTo() {
+    	dateTo.setTime(new Date(2019-1900, 4, 30));
+    	assertEquals(0,bitmap.getDateTo().getTime().toString().compareToIgnoreCase("Thu May 30 00:00:00 CEST 2019"));   
+    }
+
+    @Test
+    public void testgetLineNumber() {
+    	assertEquals(0,bitmap.getLineNumber().compareToIgnoreCase("143440"));   
+    }
+
+    @Test
+    public void testsetLineNumber() {
+    	bitmap.setLineNumber("143441");
+    	assertEquals(0,bitmap.getLineNumber().compareToIgnoreCase("143441"));  
+    }
+
+    @Test
+    public void testgetConnectionNumber() {
+    	assertEquals(0,bitmap.getConnectionNumber().compareToIgnoreCase("1")); 
+    }
+
+    @Test
+    public void testsetConnectionNumber() {
+    	bitmap.setConnectionNumber("2");
+    	assertEquals(0,bitmap.getConnectionNumber().compareToIgnoreCase("2")); 
+    }
+
+    @Test
+    public void testgetBitmap() {
+    	int[] array = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+    	assertArrayEquals(array, bitmap.getBitmap());
+    }
+
+    @Test
+    public void testsetBitmap() {
+    	int[] array = new int[] {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+    	int[] newBitmap = new int[] {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+    	bitmap.setBitmap(newBitmap);
+    	assertArrayEquals(array, bitmap.getBitmap());
+        this.bitmap = bitmap;
+    }
+
+    @Test
+    public void testgetFirstDayOfWeek() {
+    	assertEquals(4,bitmap.getFirstDayOfWeek());
+    }
+
+    @Test
+    public void testsetFirstDayOfWeek() {
+    	bitmap.setFirstDayOfWeek(5);
+    	assertEquals(5,bitmap.getFirstDayOfWeek());
+    }
+   
+    @Test
+    public void testtoString() {
+    	assertEquals(0,bitmap.toString().compareToIgnoreCase("[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]"));
+    }
+    
+    
+}
