mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
package renamed
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package org.diylc;
|
||||
|
||||
import org.diylc.plugins.file.BomMakerTest;
|
||||
import org.diylc.presenter.ClassProcessorTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@SuiteClasses( { BomMakerTest.class, ClassProcessorTest.class })
|
||||
public class AllTests {
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package org.diylc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.diylc.plugins.online.model.ProjectEntity;
|
||||
|
||||
import com.diyfever.httpproxy.ParamName;
|
||||
|
||||
public interface ProjectSearch {
|
||||
List<ProjectEntity> project_search(@ParamName("criteria") String criteria);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package org.diylc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.diylc.plugins.online.model.ProjectEntity;
|
||||
|
||||
import com.diyfever.gui.objecttable.IActionProcessor;
|
||||
import com.diyfever.gui.objecttable.ObjectListTable;
|
||||
|
||||
public class TableTest {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
BasicConfigurator.configure();
|
||||
|
||||
List<ProjectEntity> projects = new ArrayList<ProjectEntity>();
|
||||
projects.add(new ProjectEntity(1, "first", "some text", "bane", "none"));
|
||||
projects.add(new ProjectEntity(2, "second", "anoter text", "bisera", "none"));
|
||||
|
||||
ObjectListTable<ProjectEntity> t = new ObjectListTable<ProjectEntity>(ProjectEntity.class,
|
||||
new String[] { "getName", "getDescription", "getCategory", "getOwner",
|
||||
"action:Download" }, new IActionProcessor<ProjectEntity>() {
|
||||
|
||||
@Override
|
||||
public void actionExecuted(ProjectEntity value, String actionColumnName) {
|
||||
System.out.println("row clicked: " + actionColumnName + " - " + value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Icon getActionIcon(String actionColumnName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActionLabel(String actionColumnName) {
|
||||
return "get me";
|
||||
}
|
||||
});
|
||||
t.setData(projects);
|
||||
JFrame f = new JFrame();
|
||||
f.add(new JScrollPane(t));
|
||||
f.pack();
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.diylc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.diylc.plugins.online.model.ProjectEntity;
|
||||
|
||||
import com.diyfever.httpproxy.ParamName;
|
||||
import com.diyfever.httpproxy.PhpFlatProxy;
|
||||
import com.diyfever.httpproxy.ProxyFactory;
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver;
|
||||
|
||||
public class Test {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
// XStream xstream = new XStream(new JettisonMappedXmlDriver());
|
||||
// xstream.setMode(XStream.NO_REFERENCES);
|
||||
//
|
||||
// List<ProjectEntity> projects = new ArrayList<ProjectEntity>();
|
||||
// // projects.add(new ProjectEntity(1, "first project", "some text",
|
||||
// // "bancika", "some category"));
|
||||
// // projects.add(new ProjectEntity(2, "second project", "some text",
|
||||
// // "bancika", "some category"));
|
||||
// System.out.println(xstream.toXML(projects));
|
||||
|
||||
BasicConfigurator.configure();
|
||||
ProjectSearch search = new ProxyFactory(new PhpFlatProxy()).createProxy(
|
||||
ProjectSearch.class, "http://host07.dwhost.net/~diyfever/diylc/db/");
|
||||
List<ProjectEntity> results = search.project_search("TestProject");
|
||||
System.out.println(results);
|
||||
}
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package org.diylc.plugins.file;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.diylc.model.IComponentInstance;
|
||||
import org.diylc.model.measures.Capacitance;
|
||||
import org.diylc.model.measures.CapacitanceUnit;
|
||||
import org.diylc.plugins.file.BomEntry;
|
||||
import org.diylc.plugins.file.BomMaker;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.diyfever.diylc.components.MockComponentInstance;
|
||||
|
||||
public class BomMakerTest {
|
||||
|
||||
@Test
|
||||
public void testCreateBom() {
|
||||
List<IComponentInstance> components = new ArrayList<IComponentInstance>();
|
||||
MockComponentInstance c1 = new MockComponentInstance();
|
||||
c1.setC(new Capacitance(3d, CapacitanceUnit.pF));
|
||||
components.add(c1);
|
||||
components.add(new MockComponentInstance());
|
||||
components.add(new MockComponentInstance());
|
||||
List<BomEntry> bom = BomMaker.getInstance().createBom(components);
|
||||
assertNotNull(bom);
|
||||
assertEquals(2, bom.size());
|
||||
BomEntry entry1 = bom.get(0);
|
||||
assertEquals("something", entry1.getName());
|
||||
assertEquals(2, (int) entry1.getQuantity());
|
||||
BomEntry entry2 = bom.get(1);
|
||||
assertEquals("something", entry2.getName());
|
||||
assertEquals(1, (int) entry2.getQuantity());
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package org.diylc.presenter;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.diylc.common.ControlPointWrapper;
|
||||
import org.diylc.common.PropertyWrapper;
|
||||
import org.diylc.presenter.ComponentProcessor;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.diyfever.diylc.components.MockComponentInstance;
|
||||
|
||||
public class ClassProcessorTest {
|
||||
|
||||
@Test
|
||||
public void testExtractProperties() {
|
||||
List<PropertyWrapper> properties = ComponentProcessor.getInstance().extractProperties(
|
||||
MockComponentInstance.class);
|
||||
assertNotNull(properties);
|
||||
assertEquals(4, properties.size());
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testExtractControlPoints() {
|
||||
List<ControlPointWrapper> controlPoints = ComponentProcessor.getInstance()
|
||||
.extractControlPoints(MockComponentInstance.class);
|
||||
assertNotNull(controlPoints);
|
||||
assertEquals(1, controlPoints.size());
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user