r494 - in trunk/wikitty-api/src: main/java/org/nuiton/wikitty test/java/org/nuiton/wikitty/api
Author: bpoussin Date: 2010-11-22 19:55:21 +0100 (Mon, 22 Nov 2010) New Revision: 494 Url: http://nuiton.org/repositories/revision/wikitty/494 Log: add FIXME on bad code and test unit that must be passed when this code will be corrected Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java trunk/wikitty-api/src/test/java/org/nuiton/wikitty/api/WikittyUtilTest.java Modified: trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java =================================================================== --- trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-11-22 16:57:54 UTC (rev 493) +++ trunk/wikitty-api/src/main/java/org/nuiton/wikitty/WikittyUtil.java 2010-11-22 18:55:21 UTC (rev 494) @@ -944,6 +944,9 @@ result = WikittyServiceEnhanced.restore(service, securityToken, id); try { + // FIXME poussin 20101122 this is completely false :( + // we can't use BeanUtils.copyProperties to copy to Wikitty + // there are no get or set method for field BeanUtils.copyProperties(result, entity); } catch (Exception eee) { throw new WikittyException("Could not transform entity to Wikitty", eee); Modified: trunk/wikitty-api/src/test/java/org/nuiton/wikitty/api/WikittyUtilTest.java =================================================================== --- trunk/wikitty-api/src/test/java/org/nuiton/wikitty/api/WikittyUtilTest.java 2010-11-22 16:57:54 UTC (rev 493) +++ trunk/wikitty-api/src/test/java/org/nuiton/wikitty/api/WikittyUtilTest.java 2010-11-22 18:55:21 UTC (rev 494) @@ -25,18 +25,23 @@ package org.nuiton.wikitty.api; +import java.beans.PropertyChangeListener; import java.math.BigDecimal; import java.text.ParseException; +import java.util.Collection; import java.util.Collections; import java.util.Date; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; +import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; import org.junit.Test; import org.nuiton.util.ApplicationConfig; +import org.nuiton.wikitty.WikittyConfig; import org.nuiton.wikitty.WikittyService; import org.nuiton.wikitty.entities.FieldType; import org.nuiton.wikitty.entities.Wikitty; @@ -508,5 +513,128 @@ Assert.assertEquals(wikittyId, labelWikitty.getId()); Assert.assertEquals(Collections.singleton("Test"),labelWikitty.getFieldAsObject(WikittyLabel.EXT_WIKITTYLABEL,WikittyLabel.FIELD_WIKITTYLABEL_LABELS)); + + ApplicationConfig config = new WikittyConfig(); + WikittyServiceInMemory ws = new WikittyServiceInMemory(config); + + ws.store(null, Collections.singleton(labelWikitty), false); + + LabelDTO dto = new LabelDTO(); + dto.addLabels("toto"); + dto.setWikittyId(wikittyId); + dto.setWikittyVersion("2.0"); + + Wikitty w = WikittyUtil.getWikitty(ws, null, dto); + WikittyLabel l = new WikittyLabelImpl(w); + + Assert.assertEquals(dto.getWikittyId(), l.getWikittyId()); + Assert.assertEquals(dto.getWikittyVersion(), l.getWikittyVersion()); + Assert.assertEquals(dto.getLabels(), l.getLabels()); } + + static public class LabelDTO implements WikittyLabel { + + protected String wikittyId; + protected String wikittyVersion; + protected Set<String> labels = new HashSet<String>(); + + public void setWikittyId(String wikittyId) { + this.wikittyId = wikittyId; + } + + @Override + public String getWikittyId() { + return wikittyId; + } + + @Override + public String getWikittyVersion() { + return wikittyVersion; + } + + @Override + public void setWikittyVersion(String version) { + this.wikittyVersion = version; + } + + /** + * getLabels : + * @return Set<String> + */ + @Override + public Set<String> getLabels() { + return labels; + } + + public void setLabels(Set<String> labels) { + this.labels = labels; + } + + /** + * addLabels : + * @param element + */ + @Override + public void addLabels(String element) { + labels.add(element); + } + + /** + * removeLabels : + * @param element + */ + @Override + public void removeLabels(String element) { + labels.remove(element); + } + + /** + * clearLabels : + */ + @Override + public void clearLabels() { + labels.clear(); + } + + @Override + public Collection<String> getExtensionFields(String ext) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Collection<String> getExtensionNames() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Object getField(String ext, String fieldName) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void setField(String ext, String fieldName, Object value) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void addPropertyChangeListener(PropertyChangeListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void removePropertyChangeListener(PropertyChangeListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { + throw new UnsupportedOperationException("Not supported yet."); + } + + } }
Le 22/11/2010 19:55, bpoussin@users.nuiton.org a écrit :
Log: add FIXME on bad code and test unit that must be passed when this code will be corrected
@@ -944,6 +944,9 @@ result = WikittyServiceEnhanced.restore(service, securityToken, id);
try { + // FIXME poussin 20101122 this is completely false :( + // we can't use BeanUtils.copyProperties to copy to Wikitty + // there are no get or set method for field BeanUtils.copyProperties(result, entity); } catch (Exception eee) { throw new WikittyException("Could not transform entity to Wikitty", eee);
Le problème viens sur les wikittyId et version a priori. Mais normalement les DTO/wikittys/... viennent du service et donc on a déjà des wikittyId et version et donc on a pas besoin de les setter. Je dis une grosse connerie ou pas ? Du coup si on retrouve pas wikitty dans le wikitty service, on peut retourner null ?
participants (2)
-
bpoussin@users.nuiton.org -
Jean Couteau