Skip to content

Commit

Permalink
1.4.60
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagolvlsantos committed Feb 2, 2016
1 parent 6bb422f commit 7b7bfd9
Show file tree
Hide file tree
Showing 61 changed files with 1,081 additions and 44 deletions.
3 changes: 3 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
-----------------------------------------------------------
1.4.60
OK - Add converter to 'LocalDateTime' type. #29 https://github.com/thiagolvlsantos/specrunner/issues/29

1.4.59
OK - Add more boolean converters enhancement #28 https://github.com/thiagolvlsantos/specrunner/issues/28
OK - Add 'ignore=true' feature to plugin column. enhancement #26 https://github.com/thiagolvlsantos/specrunner/issues/26
Expand Down
Binary file added downloads/specrunner-1.4.60-clean.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion specrunner-ant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.specrunner</groupId>
<artifactId>specrunner</artifactId>
<version>1.4.59</version>
<version>1.4.60</version>
<relativePath>../specrunner</relativePath>
</parent>
<artifactId>specrunner-ant</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion specrunner-concordion-emulator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.specrunner</groupId>
<artifactId>specrunner</artifactId>
<version>1.4.59</version>
<version>1.4.60</version>
<relativePath>../specrunner</relativePath>
</parent>
<artifactId>specrunner-concordion-emulator</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion specrunner-core-excel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.specrunner</groupId>
<artifactId>specrunner</artifactId>
<version>1.4.59</version>
<version>1.4.60</version>
<relativePath>../specrunner</relativePath>
</parent>
<artifactId>specrunner-core-excel</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion specrunner-core-spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.specrunner</groupId>
<artifactId>specrunner</artifactId>
<version>1.4.59</version>
<version>1.4.60</version>
<relativePath>../specrunner</relativePath>
</parent>
<artifactId>specrunner-core-spring</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion specrunner-core-text/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.specrunner</groupId>
<artifactId>specrunner</artifactId>
<version>1.4.59</version>
<version>1.4.60</version>
<relativePath>../specrunner</relativePath>
</parent>
<artifactId>specrunner-core-text</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion specrunner-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.specrunner</groupId>
<artifactId>specrunner</artifactId>
<version>1.4.59</version>
<version>1.4.60</version>
<relativePath>../specrunner</relativePath>
</parent>
<artifactId>specrunner-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
SpecRunner - Acceptance Test Driven Development Tool
Copyright (C) 2011-2015 Thiago Santos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package org.specrunner.converters.core;

import org.specrunner.source.resource.ResourceException;
import org.specrunner.util.UtilIO;

/**
* Create current date.
*
* @author Thiago Santos
*
*/
@SuppressWarnings("serial")
public class ConverterDateMidnightCurrent extends ConverterDateMidnightCurrentTemplate {

/**
* Basic data converter.
*
* @throws ResourceException
* On load errors.
*/
public ConverterDateMidnightCurrent() throws ResourceException {
super(UtilIO.readLines("sr_converters_time.txt"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
SpecRunner - Acceptance Test Driven Development Tool
Copyright (C) 2011-2015 Thiago Santos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package org.specrunner.converters.core;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;

import org.joda.time.DateMidnight;
import org.specrunner.converters.ConverterException;

/**
* Create current date.
*
* @author Thiago Santos
*
*/
@SuppressWarnings("serial")
public class ConverterDateMidnightCurrentTemplate extends AbstractConverterTimeTemplate<DateMidnight> {

protected Map<String, String> aliasToField = new HashMap<String, String>();
protected Map<String, String> fieldToMethod = new HashMap<String, String>();
protected Pattern pattern;

/**
* See superclass.
*
* @param values
* Value.
*/
public ConverterDateMidnightCurrentTemplate(List<String> values) {
super(values);
pattern = extractPattern(bindAliases(aliasToField).keySet());
bindPatterns(fieldToMethod);
}

protected Map<String, String> bindAliases(Map<String, String> map) {
UtilDate.bindAliases(map);
return map;
}

protected Map<String, String> bindPatterns(Map<String, String> map) {
UtilJodatime.bindDatePatterns(map);
UtilJodatime.bindTimePatterns(map);
return map;
}

protected Pattern extractPattern(Set<String> set) {
return UtilDate.extractPattern(set);
}

@Override
protected boolean testValue(String str, String value) {
return str.startsWith(value);
}

@Override
protected DateMidnight instance() {
return new DateMidnight();
}

@Override
public Object convert(Object value, Object[] args) throws ConverterException {
if (value instanceof DateMidnight) {
return value;
}
return super.convert(value, args);
}

@Override
protected DateMidnight postProcess(Object value, Object[] args, DateMidnight result) {
return UtilJodatime.postProcess(value, args, result, pattern, aliasToField, fieldToMethod);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
SpecRunner - Acceptance Test Driven Development Tool
Copyright (C) 2011-2015 Thiago Santos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package org.specrunner.converters.core;

import java.util.TimeZone;

import org.joda.time.DateMidnight;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.specrunner.SRServices;
import org.specrunner.converters.ConverterException;
import org.specrunner.util.cache.ICache;
import org.specrunner.util.cache.ICacheFactory;

/**
* Convert any date (DateMidnight form Jodatime), given a provided pattern in
* arg[0].
*
* @author Thiago Santos
*
*/
@SuppressWarnings("serial")
public class ConverterDateMidnightPatternArgs extends AbstractConverterTimezone<DateMidnight> {
/**
* Cache of formatters.
*/
protected static ICache<String, DateTimeFormatter> cache = SRServices.get(ICacheFactory.class).newCache(ConverterDateMidnightPatternArgs.class.getName());

@Override
public Object convert(Object value, Object[] args) throws ConverterException {
if (value == null) {
return null;
}
if (value instanceof DateMidnight) {
return value;
}
try {
if (args.length < 1) {
throw new ConverterException("Converter '" + getClass() + "' missing pattern argument information (i.e. arg0=\"dd/MM/yyyy\").");
}
String pattern = String.valueOf(args[0]);
synchronized (cache) {
DateTimeFormatter formatter = cache.get(pattern);
if (formatter == null) {
formatter = DateTimeFormat.forPattern(pattern);
cache.put(pattern, formatter);
}
TimeZone tz = getZone();
if (tz != null) {
formatter = formatter.withZone(DateTimeZone.forTimeZone(tz));
}
return formatter.parseDateTime(String.valueOf(value)).toDateMidnight();
}
} catch (IllegalArgumentException e) {
throw new ConverterException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
SpecRunner - Acceptance Test Driven Development Tool
Copyright (C) 2011-2015 Thiago Santos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package org.specrunner.converters.core;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.specrunner.converters.ConverterException;

/**
* General date converter.
*
* @author Thiago Santos
*
*/
@SuppressWarnings("serial")
public class ConverterDateMidnightPatternTemplate extends ConverterNotNullNotEmpty {

/**
* Parser instance.
*/
protected DateTimeFormatter pattern;

/**
* Create a SimpleDateFormat using the given pattern.
*
* @param pattern
* Pattern.
*/
public ConverterDateMidnightPatternTemplate(String pattern) {
this.pattern = DateTimeFormat.forPattern(pattern);
}

@Override
public Object convert(Object value, Object[] args) throws ConverterException {
if (value == null) {
return null;
}
if (value instanceof DateTime) {
return value;
}
try {
return pattern.parseDateTime(String.valueOf(value)).toDateMidnight();
} catch (IllegalArgumentException e) {
throw new ConverterException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
SpecRunner - Acceptance Test Driven Development Tool
Copyright (C) 2011-2015 Thiago Santos
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package org.specrunner.converters.core;

import org.specrunner.source.resource.ResourceException;
import org.specrunner.util.UtilIO;

/**
* Create current date.
*
* @author Thiago Santos
*
*/
@SuppressWarnings("serial")
public class ConverterLocalDateTimeCurrent extends ConverterLocalDateTimeCurrentTemplate {

/**
* Basic data converter.
*
* @throws ResourceException
* On load errors.
*/
public ConverterLocalDateTimeCurrent() throws ResourceException {
super(UtilIO.readLines("sr_converters_date.txt"));
}
}
Loading

0 comments on commit 7b7bfd9

Please sign in to comment.