source: java/main/src/test/java/com/framsticks/standard/StandardStateTest.java @ 107

Last change on this file since 107 was 107, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • add SimultorProviders? hierarchy
  • start Framsticks server over SSH
  • FJF compatible with Framsticks 4.0rc3
  • reading and writing of standard.expt
  • a proof-of-concept implementation of StandardExperiment?

CHANGELOG:
Optionally return FreeAccess? from registry.

Add SimulatorRange?.

StandardExperiment? with genotypes circulation.

Automate registration around StandardState?.

More improvements to StandardExperiment?.

Skeleton version of StandardExperiment?.

Test saving of StandardState?.

Standard experiment state is being loaded.

More development towards StandardState? reading.

Work on reading standard experiment state.

Add classes for standard experiment.

Update example standard.expt

Add FreeAccess? and FreeObject?.

Made compatible with version 4.0rc3

Change deserialization policy.

Improve SSH support.

Working running simulator over SSH.

Fix joining bug in Experiment.

Working version of SimulatorRunner?.

Add more SimulatorProviders?.

Working PrimeExperimentTest? with 4.0rc3

Add references to deserialization.

Add OpaqueObject? and it's serialization.

Add deserialization of dictionaries.

Partial implementation of deserialization.

Add more tests for deserialization.

Prepare tests for deserialization.

Add proper result to prime experiment test.

Minor fixes to simulators providers.

Draft version of SimulatorProvider?.

Add SimulatorProvider? interface.

File size: 3.0 KB
Line 
1package com.framsticks.standard;
2
3import java.util.List;
4import java.util.Map;
5
6import org.testng.annotations.Test;
7
8import com.framsticks.model.Genotype;
9import com.framsticks.params.Access;
10import com.framsticks.params.AccessOperations;
11import com.framsticks.params.FramsClass;
12import com.framsticks.params.FreeObject;
13import com.framsticks.params.ListSink;
14import com.framsticks.params.PropertiesAccess;
15import com.framsticks.params.PropertiesObject;
16import com.framsticks.params.ReflectionAccess;
17import com.framsticks.params.Registry;
18import com.framsticks.params.types.UniqueListParam;
19import com.framsticks.test.TestConfiguration;
20import static org.fest.assertions.Assertions.*;
21
22@Test
23public class StandardStateTest extends TestConfiguration {
24
25
26        protected final Registry registry = new Registry();
27        protected Access stateAccess;
28
29        @Test
30        public void testLoad() {
31                registry.registerAndBuild(StandardState.class);
32
33                FramsClass stateFramsClass = registry.getFramsClassForJavaClass(StandardState.class);
34                assertThat(stateFramsClass.getParamCount()).isEqualTo(3);
35                assertThat(registry.getFramsClass("GenePool").getParam("genotypes")).isInstanceOf(UniqueListParam.class);
36
37                stateAccess = AccessOperations.loadAll(registry.createAccess(StandardState.class), getSource("/netfiles/standard.expt"), registry);
38                assertThat(stateAccess.getTypeId()).isEqualTo("StandardState");
39
40                assertThat(stateAccess.getSelected()).isInstanceOf(StandardState.class);
41                StandardState state = (StandardState) stateAccess.getSelected();
42
43                assertThat(state.simParams).isInstanceOf(FreeObject.class);
44                FreeObject simParams = (FreeObject) state.simParams;
45                assertThat(simParams.get("Energy0", Double.class)).isEqualTo(5000.0);
46
47                assertThat(state.genepools.size()).isEqualTo(1);
48                assertThat(state.populations.size()).isEqualTo(2);
49
50                assertThat(state.genepools.get(0)).isInstanceOf(PropertiesObject.class);
51
52                Access genePoolAccess = registry.bindAccessFor(state.genepools.get(0));
53                assertThat(genePoolAccess).isInstanceOf(PropertiesAccess.class);
54                assertThat(genePoolAccess.get("fitness", String.class)).isEqualTo("return 0.0+this.velocity*1.0;");
55                assertThat(genePoolAccess.get("genotypes", Object.class)).isInstanceOf(Map.class);
56                assertThat(genePoolAccess.get("genotypes", Object.class)).isInstanceOf(Map.class);
57
58                Access genotypesAccess = registry.bindAccessFor(genePoolAccess, "genotypes");
59                assertThat(genotypesAccess.getParamCount()).isEqualTo(3);
60
61                Access genotypeAccess = registry.bindAccessFor(genotypesAccess, "0");
62                assertThat(genotypeAccess).isInstanceOf(ReflectionAccess.class);
63                assertThat(genotypeAccess.getSelected()).isInstanceOf(Genotype.class);
64
65                Genotype genotype = (Genotype) genotypeAccess.getSelected();
66                assertThat(genotype.name).isEqualTo("Uwuwit Si");
67        }
68
69        @Test
70        public void testSave() {
71                List<String> out = AccessOperations.saveAll(stateAccess, new ListSink(), registry).getOut();
72                assertThat(out).contains("Genotype:", "name:Uwuwit Si");
73                // for (String l : out) {
74                //      System.out.println(l);
75                // }
76        }
77
78
79}
Note: See TracBrowser for help on using the repository browser.