From ef22a0b04c38d83e842c473be0a6367256b9eea2 Mon Sep 17 00:00:00 2001 From: Mag Date: Thu, 28 Mar 2019 10:23:37 +0100 Subject: [PATCH 01/38] increase code duplication limit to 25 tokens --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a0763c45..1d0610ee 100644 --- a/pom.xml +++ b/pom.xml @@ -97,7 +97,7 @@ maven-pmd-plugin 3.11.0 - 15 + 25 true true From 8185adba9a198c45fdec0d2fc16d521c4c02715f Mon Sep 17 00:00:00 2001 From: Tamas Szirbucz Date: Mon, 29 Apr 2019 11:21:27 +0200 Subject: [PATCH 02/38] Spring refactor of #242 --- .../assurance/ADAAssuranceManager.java | 15 ++++++ .../pdengine/assurance/AssuranceManager.java | 11 ++++ .../pdengine/votecast/CastVote.java | 27 +++++----- .../pdengine/votecast/CastVoteEntity.java | 14 ++--- .../votecast/CastVoteServiceImpl.java | 16 +++++- .../pdengine/UnimplementedTests.java | 23 -------- .../assurance/AssuranceManagerTest.java | 29 ++++++++++ .../testhelpers/CastVoteTestHelper.java | 12 ++--- .../votecast/CastVoteAssuranceTest.java | 53 +++++++++++++++++++ .../pdengine/votecast/CastVoteTestBase.java | 44 +++++++++------ 10 files changed, 179 insertions(+), 65 deletions(-) create mode 100644 src/main/java/org/rulez/demokracia/pdengine/assurance/ADAAssuranceManager.java create mode 100644 src/main/java/org/rulez/demokracia/pdengine/assurance/AssuranceManager.java delete mode 100644 src/test/java/org/rulez/demokracia/pdengine/UnimplementedTests.java create mode 100644 src/test/java/org/rulez/demokracia/pdengine/assurance/AssuranceManagerTest.java create mode 100644 src/test/java/org/rulez/demokracia/pdengine/votecast/CastVoteAssuranceTest.java diff --git a/src/main/java/org/rulez/demokracia/pdengine/assurance/ADAAssuranceManager.java b/src/main/java/org/rulez/demokracia/pdengine/assurance/ADAAssuranceManager.java new file mode 100644 index 00000000..65bc402a --- /dev/null +++ b/src/main/java/org/rulez/demokracia/pdengine/assurance/ADAAssuranceManager.java @@ -0,0 +1,15 @@ +package org.rulez.demokracia.pdengine.assurance; + +import java.util.List; + +import org.springframework.stereotype.Service; + +@Service +public class ADAAssuranceManager implements AssuranceManager { + + @Override + public List getAssurances(final String proxyId) { + throw new UnsupportedOperationException(); + } + +} diff --git a/src/main/java/org/rulez/demokracia/pdengine/assurance/AssuranceManager.java b/src/main/java/org/rulez/demokracia/pdengine/assurance/AssuranceManager.java new file mode 100644 index 00000000..5d3ef23f --- /dev/null +++ b/src/main/java/org/rulez/demokracia/pdengine/assurance/AssuranceManager.java @@ -0,0 +1,11 @@ +package org.rulez.demokracia.pdengine.assurance; + +import java.util.List; + +import org.springframework.stereotype.Service; + +@Service +public interface AssuranceManager { + + List getAssurances(String proxyId); +} diff --git a/src/main/java/org/rulez/demokracia/pdengine/votecast/CastVote.java b/src/main/java/org/rulez/demokracia/pdengine/votecast/CastVote.java index 6dc2c937..26c863fd 100644 --- a/src/main/java/org/rulez/demokracia/pdengine/votecast/CastVote.java +++ b/src/main/java/org/rulez/demokracia/pdengine/votecast/CastVote.java @@ -6,19 +6,22 @@ import org.rulez.demokracia.pdengine.RandomUtils; import org.rulez.demokracia.pdengine.choice.RankedChoice; - public class CastVote extends CastVoteEntity implements CastVoteInterface { - private static final long serialVersionUID = 1L; - public CastVote(final String proxyId, final List preferences) { - super(); - this.setProxyId(proxyId); - this.setPreferences(new ArrayList<>(preferences)); - setSecretId(RandomUtils.createRandomKey()); - } + private static final long serialVersionUID = 1L; + + public CastVote(final String proxyId, final List preferences) { + super(); + setProxyId(proxyId); + setPreferences(new ArrayList<>(preferences)); + setSecretId(RandomUtils.createRandomKey()); + } - @Override - public List getAssurances() { - throw new UnsupportedOperationException(); - } + public CastVote( + final String proxyId, final List preferences, + final List assurances + ) { + this(proxyId, preferences); + setAssurances(assurances); + } } diff --git a/src/main/java/org/rulez/demokracia/pdengine/votecast/CastVoteEntity.java b/src/main/java/org/rulez/demokracia/pdengine/votecast/CastVoteEntity.java index bbae8def..547c5679 100644 --- a/src/main/java/org/rulez/demokracia/pdengine/votecast/CastVoteEntity.java +++ b/src/main/java/org/rulez/demokracia/pdengine/votecast/CastVoteEntity.java @@ -15,11 +15,13 @@ @Setter @Entity public class CastVoteEntity extends BaseEntity { - private static final long serialVersionUID = 1L; - @ElementCollection - private List preferences; - private String proxyId; - private String secretId; - private String signature; + + private static final long serialVersionUID = 1L; + @ElementCollection + private List preferences; + private String proxyId; + private String secretId; + private String signature; + private List assurances; } diff --git a/src/main/java/org/rulez/demokracia/pdengine/votecast/CastVoteServiceImpl.java b/src/main/java/org/rulez/demokracia/pdengine/votecast/CastVoteServiceImpl.java index d5636344..4434a2dc 100644 --- a/src/main/java/org/rulez/demokracia/pdengine/votecast/CastVoteServiceImpl.java +++ b/src/main/java/org/rulez/demokracia/pdengine/votecast/CastVoteServiceImpl.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Objects; +import org.rulez.demokracia.pdengine.assurance.AssuranceManager; import org.rulez.demokracia.pdengine.authentication.AuthenticatedUserService; import org.rulez.demokracia.pdengine.choice.RankedChoice; import org.rulez.demokracia.pdengine.vote.Vote; @@ -22,6 +23,9 @@ public class CastVoteServiceImpl implements CastVoteService { @Autowired private VoteService voteService; + @Autowired + private AssuranceManager assuranceManager; + @Override public CastVote castVote( final String voteId, final String ballot, @@ -45,11 +49,21 @@ public CastVote castVote( vote.getVotesCast() .removeIf(castVote -> proxyId.equals(castVote.getProxyId())); - final CastVote castVote = new CastVote(proxyId, rankedChoices); + final CastVote castVote = createCastVote(rankedChoices, proxyId); vote.getVotesCast().add(castVote); return castVote; } + private CastVote + createCastVote( + final List rankedChoices, final String proxyId + ) { + return Objects.isNull(proxyId) ? new CastVote(proxyId, rankedChoices) : + new CastVote( + proxyId, rankedChoices, assuranceManager.getAssurances(proxyId) + ); + } + private void validateInput( final String ballot, final List rankedChoices, final Vote vote diff --git a/src/test/java/org/rulez/demokracia/pdengine/UnimplementedTests.java b/src/test/java/org/rulez/demokracia/pdengine/UnimplementedTests.java deleted file mode 100644 index f10689e4..00000000 --- a/src/test/java/org/rulez/demokracia/pdengine/UnimplementedTests.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.rulez.demokracia.pdengine; - -import java.util.ArrayList; - -import org.junit.Test; -import org.rulez.demokracia.pdengine.annotations.TestedBehaviour; -import org.rulez.demokracia.pdengine.annotations.TestedFeature; -import org.rulez.demokracia.pdengine.annotations.TestedOperation; -import org.rulez.demokracia.pdengine.testhelpers.ThrowableTester; -import org.rulez.demokracia.pdengine.votecast.CastVote; - -@TestedFeature("Unimplemented") -@TestedOperation("Unimplemented") -@TestedBehaviour("Unimplemented") -public class UnimplementedTests extends ThrowableTester { - - @Test - public void the_getAssurances_method_is_not_implemented_yet() { - assertUnimplemented( - () -> new CastVote("proxyId", new ArrayList<>()).getAssurances() - ); - } -} diff --git a/src/test/java/org/rulez/demokracia/pdengine/assurance/AssuranceManagerTest.java b/src/test/java/org/rulez/demokracia/pdengine/assurance/AssuranceManagerTest.java new file mode 100644 index 00000000..d0642a60 --- /dev/null +++ b/src/test/java/org/rulez/demokracia/pdengine/assurance/AssuranceManagerTest.java @@ -0,0 +1,29 @@ +package org.rulez.demokracia.pdengine.assurance; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.junit.MockitoJUnitRunner; +import org.rulez.demokracia.pdengine.annotations.TestedBehaviour; +import org.rulez.demokracia.pdengine.annotations.TestedFeature; +import org.rulez.demokracia.pdengine.annotations.TestedOperation; +import org.rulez.demokracia.pdengine.testhelpers.ThrowableTester; + +@TestedFeature("Supporting functionality") +@TestedOperation("Assurance management") +@TestedBehaviour("Unimplemented") +@RunWith(MockitoJUnitRunner.class) +public class AssuranceManagerTest extends ThrowableTester { + + private static final String PROXY_ID = "proxyId"; + + @InjectMocks + private ADAAssuranceManager assuranceManager; + + @Test + public void getAssurances_is_unimplemented_yet() throws Exception { + assertUnimplemented( + () -> assuranceManager.getAssurances(PROXY_ID) + ); + } +} diff --git a/src/test/java/org/rulez/demokracia/pdengine/testhelpers/CastVoteTestHelper.java b/src/test/java/org/rulez/demokracia/pdengine/testhelpers/CastVoteTestHelper.java index a30fa876..b6aafa1c 100644 --- a/src/test/java/org/rulez/demokracia/pdengine/testhelpers/CastVoteTestHelper.java +++ b/src/test/java/org/rulez/demokracia/pdengine/testhelpers/CastVoteTestHelper.java @@ -11,16 +11,16 @@ public class CastVoteTestHelper { public static final Choice CHOICE_A = new Choice("A", "user"); public static final Choice CHOICE_B = new Choice("B", "user"); + public static final List RANKED_CHOICES = + List.of(new RankedChoice(CHOICE_A.getId(), 1)); public static void fillVoteWithDummyCastVotes(final Vote vote) { vote.addChoice(CHOICE_A); vote.addChoice(CHOICE_B); - final List rankedChoices = - List.of(new RankedChoice(CHOICE_A.getId(), 1)); - vote.getVotesCast().add(new CastVote("user1", rankedChoices)); - vote.getVotesCast().add(new CastVote("user2", rankedChoices)); - vote.getVotesCast().add(new CastVote(null, rankedChoices)); - vote.getVotesCast().add(new CastVote("user3", rankedChoices)); + vote.getVotesCast().add(new CastVote("user1", RANKED_CHOICES)); + vote.getVotesCast().add(new CastVote("user2", RANKED_CHOICES)); + vote.getVotesCast().add(new CastVote(null, RANKED_CHOICES)); + vote.getVotesCast().add(new CastVote("user3", RANKED_CHOICES)); } } diff --git a/src/test/java/org/rulez/demokracia/pdengine/votecast/CastVoteAssuranceTest.java b/src/test/java/org/rulez/demokracia/pdengine/votecast/CastVoteAssuranceTest.java new file mode 100644 index 00000000..fd53f4c5 --- /dev/null +++ b/src/test/java/org/rulez/demokracia/pdengine/votecast/CastVoteAssuranceTest.java @@ -0,0 +1,53 @@ +package org.rulez.demokracia.pdengine.votecast; + +import static org.junit.Assert.*; +import static org.mockito.Mockito.when; +import static org.rulez.demokracia.pdengine.testhelpers.CastVoteTestHelper.RANKED_CHOICES; + +import java.util.Objects; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; +import org.rulez.demokracia.pdengine.annotations.TestedBehaviour; +import org.rulez.demokracia.pdengine.annotations.TestedFeature; +import org.rulez.demokracia.pdengine.annotations.TestedOperation; + +@TestedFeature("Supporting functionality") +@TestedOperation("CastVote") +@RunWith(MockitoJUnitRunner.class) +public class CastVoteAssuranceTest extends CastVoteTestBase { + + @Override + @Before + public void setUp() { + super.setUp(); + when(authService.getAuthenticatedUserName()).thenReturn(USER_NAME); + when(assuranceManager.getAssurances(USER_NAME)) + .thenReturn(ASSURANCES); + } + + @TestedBehaviour( + "The assurances of the voter can be obtained from a cast vote if canupdateis true" + ) + @Test + public void + the_assurances_of_the_voter_can_be_obtained_from_a_cast_vote_if_canupdate_is_true() { + vote.getParameters().setUpdatable(true); + final CastVote castVote = castVoteService + .castVote(vote.getId(), ballot, RANKED_CHOICES); + assertEquals(ASSURANCES, castVote.getAssurances()); + } + + @TestedBehaviour( + "The assurances of the voter can be obtained from a cast vote if canupdateis true" + ) + @Test + public void the_assurances_of_the_voter_is_null_if_canupdate_is_false() { + vote.getParameters().setUpdatable(false); + final CastVote castVote = castVoteService + .castVote(vote.getId(), ballot, RANKED_CHOICES); + assertTrue(Objects.isNull(castVote.getAssurances())); + } +} diff --git a/src/test/java/org/rulez/demokracia/pdengine/votecast/CastVoteTestBase.java b/src/test/java/org/rulez/demokracia/pdengine/votecast/CastVoteTestBase.java index 10e81211..07bac973 100644 --- a/src/test/java/org/rulez/demokracia/pdengine/votecast/CastVoteTestBase.java +++ b/src/test/java/org/rulez/demokracia/pdengine/votecast/CastVoteTestBase.java @@ -2,10 +2,13 @@ import static org.mockito.Mockito.when; +import java.util.List; + import org.apache.catalina.connector.CoyotePrincipal; import org.junit.Before; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.rulez.demokracia.pdengine.assurance.AssuranceManager; import org.rulez.demokracia.pdengine.authentication.AuthenticatedUserService; import org.rulez.demokracia.pdengine.testhelpers.CastVoteTestHelper; import org.rulez.demokracia.pdengine.testhelpers.ThrowableTester; @@ -15,25 +18,32 @@ public class CastVoteTestBase extends ThrowableTester { - @InjectMocks - protected CastVoteServiceImpl castVoteService; + protected static final String USER_NAME = "name"; + + protected static final List ASSURANCES = List.of("madjare", "inglis"); + + @InjectMocks + protected CastVoteServiceImpl castVoteService; - @Mock - protected VoteService voteService; - @Mock - protected AuthenticatedUserService authService; + @Mock + protected VoteService voteService; + @Mock + protected AuthenticatedUserService authService; + @Mock + protected AssuranceManager assuranceManager; - protected Vote vote = new VariantVote(); + protected Vote vote = new VariantVote(); - protected String ballot = "ballotgyorgy"; + protected String ballot = "ballotgyorgy"; - @Before - public void setUp() { - when(voteService.getVote(vote.getId())).thenReturn(vote); - when(authService.getUserPrincipal()).thenReturn(new CoyotePrincipal("name")); - vote.getParameters().setVotable(true); - vote.getParameters().setUpdatable(true); - CastVoteTestHelper.fillVoteWithDummyCastVotes(vote); - vote.addBallot(ballot); - } + @Before + public void setUp() { + when(voteService.getVote(vote.getId())).thenReturn(vote); + when(authService.getUserPrincipal()) + .thenReturn(new CoyotePrincipal(USER_NAME)); + vote.getParameters().setVotable(true); + vote.getParameters().setUpdatable(true); + CastVoteTestHelper.fillVoteWithDummyCastVotes(vote); + vote.addBallot(ballot); + } } From 236dcb228ffc8beb65c28a7d83a3cebd1cf392cc Mon Sep 17 00:00:00 2001 From: Tamas Szirbucz Date: Tue, 30 Apr 2019 14:58:36 +0200 Subject: [PATCH 03/38] Rename choices to winner list and write test case. #219 --- .../pdengine/votecalculator/VoteResult.java | 6 +- .../VoteResultComposerImpl.java | 88 ++++++++++--------- .../VoteResultComposerTest.java | 42 ++------- .../votecalculator/VoteResultTestBase.java | 45 ++++++++++ .../VoteResultWinnerListTest.java | 43 +++++++++ 5 files changed, 144 insertions(+), 80 deletions(-) create mode 100644 src/test/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultTestBase.java create mode 100644 src/test/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultWinnerListTest.java diff --git a/src/main/java/org/rulez/demokracia/pdengine/votecalculator/VoteResult.java b/src/main/java/org/rulez/demokracia/pdengine/votecalculator/VoteResult.java index 03e7f011..642165f0 100644 --- a/src/main/java/org/rulez/demokracia/pdengine/votecalculator/VoteResult.java +++ b/src/main/java/org/rulez/demokracia/pdengine/votecalculator/VoteResult.java @@ -17,15 +17,15 @@ public class VoteResult extends BaseEntity { private static final long serialVersionUID = 1L; @ElementCollection - private final List choices; + private final List winners; @ElementCollection private final Map beats; public VoteResult( - final List choices, final Map beats + final List winners, final Map beats ) { super(); - this.choices = choices; + this.winners = winners; this.beats = beats; } diff --git a/src/main/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultComposerImpl.java b/src/main/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultComposerImpl.java index a6d4d6cb..06d9300a 100644 --- a/src/main/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultComposerImpl.java +++ b/src/main/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultComposerImpl.java @@ -15,53 +15,59 @@ @Service public class VoteResultComposerImpl implements VoteResultComposer { - @Autowired - private WinnerCalculatorService winnerCalculator; + @Autowired + private WinnerCalculatorService winnerCalculator; - private final Set ignoredSet; + private final Set ignoredSet; - public VoteResultComposerImpl() { - winnerCalculator = new WinnerCalculatorServiceImpl(); - ignoredSet = new HashSet<>(); - } + public VoteResultComposerImpl() { + winnerCalculator = new WinnerCalculatorServiceImpl(); + ignoredSet = new HashSet<>(); + } - @Override - public List composeResult(final BeatTable beatTable) { - List result = new ArrayList<>(); - HashSet keyCollection = new HashSet<>(beatTable.getKeyCollection()); - while (!ignoredSet.equals(keyCollection)) { - List winners = winnerCalculator.calculateWinners(beatTable, ignoredSet); + @Override + public List composeResult(final BeatTable beatTable) { + final List result = new ArrayList<>(); + final HashSet keyCollection = + new HashSet<>(beatTable.getKeyCollection()); + while (!ignoredSet.equals(keyCollection)) { + final List winners = + winnerCalculator.calculateWinners(beatTable, ignoredSet); - result.add(createVoteResult(beatTable, winners)); - ignoredSet.addAll(winners); - } - return result; - } + result.add(createVoteResult(beatTable, winners)); + ignoredSet.addAll(winners); + } + return result; + } - private VoteResult createVoteResult(final BeatTable beatTable, final List winners) { - return new VoteResult(winners, getBeats(winners, beatTable)); - } + private VoteResult + createVoteResult(final BeatTable beatTable, final List winners) { + return new VoteResult(winners, getBeats(winners, beatTable)); + } - private Map getBeats(final List choices, final BeatTable beatTable) { - Map result = new ConcurrentHashMap<>(); - choices.stream().forEach(c -> result.put(c, getBeatsForChoice(c, beatTable))); - return result; - } + private Map + getBeats(final List choices, final BeatTable beatTable) { + final Map result = new ConcurrentHashMap<>(); + choices.stream() + .forEach(c -> result.put(c, getBeatsForChoice(c, beatTable))); + return result; + } - private VoteResultBeat getBeatsForChoice(final String choice, final BeatTable beatTable) { - Pair zeroPair = new Pair(0, 0); - VoteResultBeat result = new VoteResultBeat(); - for (String row : beatTable.getKeyCollection()) { - Pair beat = beatTable.getElement(row, choice); - if (!zeroPair.equals(beat)) { - result.getBeats().put(row, beat); - } - } - return result; - } + private VoteResultBeat + getBeatsForChoice(final String choice, final BeatTable beatTable) { + final Pair zeroPair = new Pair(0, 0); + final VoteResultBeat result = new VoteResultBeat(); + for (final String row : beatTable.getKeyCollection()) { + final Pair beat = beatTable.getElement(row, choice); + if (!zeroPair.equals(beat)) + result.getBeats().put(row, beat); + } + return result; + } - @Override - public void setWinnerCalculator(final WinnerCalculatorService winnerCalculator) { - this.winnerCalculator = winnerCalculator; - } + @Override + public void + setWinnerCalculator(final WinnerCalculatorService winnerCalculator) { + this.winnerCalculator = winnerCalculator; + } } diff --git a/src/test/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultComposerTest.java b/src/test/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultComposerTest.java index 6a304ac9..173adf3f 100644 --- a/src/test/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultComposerTest.java +++ b/src/test/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultComposerTest.java @@ -1,51 +1,28 @@ package org.rulez.demokracia.pdengine.votecalculator; import static org.junit.Assert.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; import java.util.List; -import java.util.Set; import java.util.stream.Collectors; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.rulez.demokracia.pdengine.annotations.TestedBehaviour; import org.rulez.demokracia.pdengine.annotations.TestedFeature; import org.rulez.demokracia.pdengine.annotations.TestedOperation; -import org.rulez.demokracia.pdengine.testhelpers.BeatTableTestHelper; @TestedFeature("Vote") @TestedOperation("Compute vote results") @TestedBehaviour("the winners list contains the looses to the first one") @RunWith(MockitoJUnitRunner.class) -public class VoteResultComposerTest { - - @InjectMocks - private VoteResultComposerImpl voteResultComposer; - @Mock - private WinnerCalculatorService winnerCalculatorService; - - private Set choicesReturned; - private Set keySetOfInitialBeatTable; - private List result; +public class VoteResultComposerTest extends VoteResultTestBase { @Before + @Override public void setUp() { - when(winnerCalculatorService.calculateWinners(any(), any())) - .thenReturn(List.of("A", "B")) - .thenReturn(List.of("C")) - .thenReturn(List.of("D")); - - result = voteResultComposer - .composeResult(BeatTableTestHelper.createTransitiveClosedBeatTable()); - choicesReturned = convertResultToChoiceSet(result); - keySetOfInitialBeatTable = Set.of("A", "B", "C", "D"); - + super.setUp(); } @Test @@ -55,7 +32,7 @@ public void compute_vote_results_returns_every_choice() { @Test public void compute_vote_results_returns_each_choices_once() { - List keyList = result.stream().map(VoteResult::getChoices) + final List keyList = result.stream().map(VoteResult::getWinners) .flatMap(List::stream) .collect(Collectors.toList()); assertEquals(keyList.size(), choicesReturned.size()); @@ -63,13 +40,13 @@ public void compute_vote_results_returns_each_choices_once() { @Test public void compute_vote_results_assigns_no_beat_to_winners() { - int winnersLoses = getNumberOfBeats(result.get(0)); + final int winnersLoses = getNumberOfBeats(result.get(0)); assertEquals(0, winnersLoses); } @Test public void compute_vote_results_return_nonzero_loses_for_nonwinners() { - for (VoteResult choiceMap : result.subList(1, result.size())) + for (final VoteResult choiceMap : result.subList(1, result.size())) assertEachChoiceHaveBeaten(choiceMap); } @@ -84,11 +61,4 @@ private Integer getNumberOfBeats(final VoteResult voteResult) { return voteResult.getBeats().values().stream().map(m -> m.getBeats().size()) .reduce((a, b) -> a + b).get(); } - - private Set convertResultToChoiceSet(final List result) { - return result.stream() - .map(voteResult -> voteResult.getChoices()) - .flatMap(List::stream) - .collect(Collectors.toSet()); - } } diff --git a/src/test/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultTestBase.java b/src/test/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultTestBase.java new file mode 100644 index 00000000..e0cad8bc --- /dev/null +++ b/src/test/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultTestBase.java @@ -0,0 +1,45 @@ +package org.rulez.demokracia.pdengine.votecalculator; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import org.junit.Before; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.rulez.demokracia.pdengine.testhelpers.BeatTableTestHelper; + +public class VoteResultTestBase { + + @InjectMocks + private VoteResultComposerImpl voteResultComposer; + @Mock + private WinnerCalculatorService winnerCalculatorService; + + protected Set choicesReturned; + protected Set keySetOfInitialBeatTable; + protected List result; + + @Before + public void setUp() { + when(winnerCalculatorService.calculateWinners(any(), any())) + .thenReturn(List.of("A", "B")) + .thenReturn(List.of("C")) + .thenReturn(List.of("D")); + + result = voteResultComposer + .composeResult(BeatTableTestHelper.createTransitiveClosedBeatTable()); + choicesReturned = convertResultToChoiceSet(result); + keySetOfInitialBeatTable = Set.of("A", "B", "C", "D"); + } + + private Set convertResultToChoiceSet(final List result) { + return result.stream() + .map(VoteResult::getWinners) + .flatMap(List::stream) + .collect(Collectors.toSet()); + } +} diff --git a/src/test/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultWinnerListTest.java b/src/test/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultWinnerListTest.java new file mode 100644 index 00000000..34347553 --- /dev/null +++ b/src/test/java/org/rulez/demokracia/pdengine/votecalculator/VoteResultWinnerListTest.java @@ -0,0 +1,43 @@ +package org.rulez.demokracia.pdengine.votecalculator; + +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; +import org.rulez.demokracia.pdengine.annotations.TestedBehaviour; +import org.rulez.demokracia.pdengine.annotations.TestedFeature; +import org.rulez.demokracia.pdengine.annotations.TestedOperation; + +@TestedFeature("Vote") +@TestedOperation("Compute vote results") +@TestedBehaviour("calculates and stores winner list") +@RunWith(MockitoJUnitRunner.class) +public class VoteResultWinnerListTest extends VoteResultTestBase { + + @Before + @Override + public void setUp() { + super.setUp(); + } + + @Test + public void vote_result_contains_winners_list() { + final List> expectedWinners = + List.of(List.of("A", "B"), List.of("C"), List.of("D")); + assertAllVoteResultContainsWinners(expectedWinners, result); + } + + private void assertAllVoteResultContainsWinners( + final List> expectedWinners, final List result + ) { + for (int i = 0; i < result.size(); ++i) + assertTrue( + result.get(i).getWinners().containsAll(expectedWinners.get(i)) + ); + } + +} From dd0925c87c7c48677dd73617d06791a205f4ad1c Mon Sep 17 00:00:00 2001 From: Tamas Szirbucz Date: Fri, 3 May 2019 15:36:33 +0200 Subject: [PATCH 04/38] Add tallying to computed vote for each counted assurance. #207 --- .../demokracia/pdengine/tally/Tally.java | 19 ++++++ .../pdengine/tally/TallyService.java | 12 ++++ .../pdengine/votecalculator/ComputedVote.java | 4 ++ .../votecalculator/ComputedVoteInterface.java | 8 --- .../ComputedVoteServiceImpl.java | 65 +++++++++++++------ .../ComputedVoteTallyingTest.java | 40 ++++++++++++ .../votecalculator/ComputedVoteTest.java | 54 ++------------- .../votecalculator/ComputedVoteTestBase.java | 65 +++++++++++++++++++ 8 files changed, 190 insertions(+), 77 deletions(-) create mode 100644 src/main/java/org/rulez/demokracia/pdengine/tally/Tally.java create mode 100644 src/main/java/org/rulez/demokracia/pdengine/tally/TallyService.java delete mode 100644 src/main/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteInterface.java create mode 100644 src/test/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteTallyingTest.java create mode 100644 src/test/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteTestBase.java diff --git a/src/main/java/org/rulez/demokracia/pdengine/tally/Tally.java b/src/main/java/org/rulez/demokracia/pdengine/tally/Tally.java new file mode 100644 index 00000000..f9a785c6 --- /dev/null +++ b/src/main/java/org/rulez/demokracia/pdengine/tally/Tally.java @@ -0,0 +1,19 @@ +package org.rulez.demokracia.pdengine.tally; + +import javax.persistence.Entity; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@Entity +public class Tally { + + private String assurance; + + public Tally(final String assurance) { + this.assurance = assurance; + } + +} diff --git a/src/main/java/org/rulez/demokracia/pdengine/tally/TallyService.java b/src/main/java/org/rulez/demokracia/pdengine/tally/TallyService.java new file mode 100644 index 00000000..4f97c8b1 --- /dev/null +++ b/src/main/java/org/rulez/demokracia/pdengine/tally/TallyService.java @@ -0,0 +1,12 @@ +package org.rulez.demokracia.pdengine.tally; + +import java.util.List; + +import org.rulez.demokracia.pdengine.votecast.CastVote; +import org.springframework.stereotype.Service; + +@Service +public interface TallyService { + + Tally calculateTally(String assurance, List castVotes); +} diff --git a/src/main/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVote.java b/src/main/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVote.java index 7c505efc..c798de6a 100644 --- a/src/main/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVote.java +++ b/src/main/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVote.java @@ -1,12 +1,14 @@ package org.rulez.demokracia.pdengine.votecalculator; import java.util.List; +import java.util.Map; import javax.persistence.ElementCollection; import javax.persistence.Entity; import org.rulez.demokracia.pdengine.beattable.BeatTable; import org.rulez.demokracia.pdengine.persistence.BaseEntity; +import org.rulez.demokracia.pdengine.tally.Tally; import org.rulez.demokracia.pdengine.vote.Vote; import lombok.Getter; @@ -23,6 +25,8 @@ public class ComputedVote extends BaseEntity { private BeatTable beatPathTable; @ElementCollection private List voteResults; + @ElementCollection + private Map tallying; public ComputedVote(final Vote vote) { super(); diff --git a/src/main/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteInterface.java b/src/main/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteInterface.java deleted file mode 100644 index 7bee3807..00000000 --- a/src/main/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteInterface.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.rulez.demokracia.pdengine.votecalculator; - -import java.util.List; - -public interface ComputedVoteInterface { - - List computeVote(); -} diff --git a/src/main/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteServiceImpl.java b/src/main/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteServiceImpl.java index 800aa98f..e245f6ce 100644 --- a/src/main/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteServiceImpl.java +++ b/src/main/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteServiceImpl.java @@ -1,8 +1,13 @@ package org.rulez.demokracia.pdengine.votecalculator; +import java.util.Map; +import java.util.stream.Collectors; + import org.rulez.demokracia.pdengine.beattable.BeatTable; import org.rulez.demokracia.pdengine.beattable.BeatTableService; import org.rulez.demokracia.pdengine.beattable.BeatTableTransitiveClosureService; +import org.rulez.demokracia.pdengine.tally.Tally; +import org.rulez.demokracia.pdengine.tally.TallyService; import org.rulez.demokracia.pdengine.vote.Vote; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -10,24 +15,44 @@ @Service public class ComputedVoteServiceImpl implements ComputedVoteService { - @Autowired - private VoteResultComposer voteResultComposer; - - @Autowired - private BeatTableService beatTableService; - - @Autowired - private BeatTableTransitiveClosureService beatTableTransitiveClosureService; - - @Override - public ComputedVote computeVote(final Vote vote) { - ComputedVote result = new ComputedVote(vote); - - result.setBeatTable(beatTableService.initializeBeatTable(vote.getVotesCast())); - BeatTable beatPathTable = beatTableService.normalize(result.getBeatTable()); - result.setBeatPathTable(beatTableTransitiveClosureService.computeTransitiveClosure(beatPathTable)); - result.setVoteResults(voteResultComposer.composeResult(result.getBeatPathTable())); - - return result; - } + @Autowired + private VoteResultComposer voteResultComposer; + + @Autowired + private BeatTableService beatTableService; + + @Autowired + private BeatTableTransitiveClosureService beatTableTransitiveClosureService; + + @Autowired + private TallyService tallyService; + + @Override + public ComputedVote computeVote(final Vote vote) { + final ComputedVote result = new ComputedVote(vote); + + result.setBeatTable( + beatTableService.initializeBeatTable(vote.getVotesCast()) + ); + final BeatTable beatPathTable = + beatTableService.normalize(result.getBeatTable()); + result + .setBeatPathTable( + beatTableTransitiveClosureService + .computeTransitiveClosure(beatPathTable) + ); + result.setVoteResults( + voteResultComposer.composeResult(result.getBeatPathTable()) + ); + + result.setTallying(computeTallying(vote)); + + return result; + } + + private Map computeTallying(final Vote vote) { + return vote.getCountedAssurances().stream().map( + a -> tallyService.calculateTally(a, vote.getVotesCast()) + ).collect(Collectors.toMap(Tally::getAssurance, t -> t)); + } } diff --git a/src/test/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteTallyingTest.java b/src/test/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteTallyingTest.java new file mode 100644 index 00000000..c4f9f12e --- /dev/null +++ b/src/test/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteTallyingTest.java @@ -0,0 +1,40 @@ +package org.rulez.demokracia.pdengine.votecalculator; + +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; +import org.rulez.demokracia.pdengine.annotations.TestedBehaviour; +import org.rulez.demokracia.pdengine.annotations.TestedFeature; +import org.rulez.demokracia.pdengine.annotations.TestedOperation; + +@TestedFeature("Vote") +@TestedOperation("Compute vote results") +@TestedBehaviour("the result contains tallying for each counted assurances") +@RunWith(MockitoJUnitRunner.class) +public class ComputedVoteTallyingTest extends ComputedVoteTestBase { + + @Override + @Before + public void setUp() { + super.setUp(); + } + + @Test + public void vote_result_contains_tally_for_each_counted_assurances() { + assertTrue( + computedVote.getTallying().keySet() + .containsAll(vote.getCountedAssurances()) + ); + } + + @Test + public void vote_result_contains_tally_only_for_counted_assurances() { + assertTrue( + vote.getCountedAssurances() + .containsAll(computedVote.getTallying().keySet()) + ); + } +} diff --git a/src/test/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteTest.java b/src/test/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteTest.java index 4437b412..d7458148 100644 --- a/src/test/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteTest.java +++ b/src/test/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteTest.java @@ -1,67 +1,23 @@ package org.rulez.demokracia.pdengine.votecalculator; import static org.junit.Assert.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.verify; import static org.rulez.demokracia.pdengine.testhelpers.BeatTableTestHelper.*; -import java.util.List; import java.util.Set; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.rulez.demokracia.pdengine.RandomUtils; import org.rulez.demokracia.pdengine.annotations.TestedBehaviour; import org.rulez.demokracia.pdengine.annotations.TestedFeature; import org.rulez.demokracia.pdengine.annotations.TestedOperation; import org.rulez.demokracia.pdengine.beattable.BeatTable; -import org.rulez.demokracia.pdengine.beattable.BeatTableService; -import org.rulez.demokracia.pdengine.beattable.BeatTableTransitiveClosureService; -import org.rulez.demokracia.pdengine.testhelpers.VariantVote; -import org.rulez.demokracia.pdengine.testhelpers.VoteResultTestHelper; -import org.rulez.demokracia.pdengine.votecast.CastVote; @TestedFeature("Vote") @TestedOperation("Compute vote results") @RunWith(MockitoJUnitRunner.class) -public class ComputedVoteTest { - - @InjectMocks - private ComputedVoteServiceImpl computedVoteService; - - @Mock - private BeatTableService beatTableService; - - @Mock - private BeatTableTransitiveClosureService beatTableTransitiveClosureService; - - @Mock - private VoteResultComposer voteResultComposer; - - private ComputedVote computedVote; - - @Before - public void setUp() { - when(beatTableService.initializeBeatTable(any())) - .thenReturn(createNewBeatTableWithComplexData()); - List keys = List.of("A", "B", "C", "D"); - when(beatTableService.normalize(any())) - .thenReturn(createTransitiveClosedBeatTable(keys)); - when(beatTableTransitiveClosureService.computeTransitiveClosure(any())) - .thenReturn(createTransitiveClosedBeatTable(keys)); - when(voteResultComposer.composeResult(any())) - .thenReturn(VoteResultTestHelper.createVoteResults()); - - VariantVote vote = new VariantVote(); - vote.setVotesCast( - List.of(new CastVote(RandomUtils.createRandomKey(), List.of())) - ); - computedVote = computedVoteService.computeVote(vote); - } +public class ComputedVoteTest extends ComputedVoteTestBase { @TestedBehaviour("compares and stores initial beat matrix") @Test @@ -109,8 +65,8 @@ public void vote_results_stored_in_computed_vote() { private void assertBeatTableEquals( final BeatTable firstBeatTable, final BeatTable secondBeatTable ) { - for (String choice1 : firstBeatTable.getKeyCollection()) - for (String choice2 : firstBeatTable.getKeyCollection()) + for (final String choice1 : firstBeatTable.getKeyCollection()) + for (final String choice2 : firstBeatTable.getKeyCollection()) assertEquals( secondBeatTable.getElement(choice1, choice2), firstBeatTable.getElement(choice1, choice2) ); @@ -122,7 +78,7 @@ private void assertBeatTableEquals( @Test public void vote_result_includes_the_votes_cast_with_the_secret_cast_vote_id() { - String secretId = + final String secretId = computedVote.getVote().getVotesCast().get(0).getSecretId(); assertFalse(secretId.isEmpty()); } diff --git a/src/test/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteTestBase.java b/src/test/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteTestBase.java new file mode 100644 index 00000000..44c1526b --- /dev/null +++ b/src/test/java/org/rulez/demokracia/pdengine/votecalculator/ComputedVoteTestBase.java @@ -0,0 +1,65 @@ +package org.rulez.demokracia.pdengine.votecalculator; + +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.when; +import static org.rulez.demokracia.pdengine.testhelpers.BeatTableTestHelper.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.rulez.demokracia.pdengine.RandomUtils; +import org.rulez.demokracia.pdengine.beattable.BeatTableService; +import org.rulez.demokracia.pdengine.beattable.BeatTableTransitiveClosureService; +import org.rulez.demokracia.pdengine.tally.Tally; +import org.rulez.demokracia.pdengine.tally.TallyService; +import org.rulez.demokracia.pdengine.testhelpers.VoteResultTestHelper; +import org.rulez.demokracia.pdengine.vote.Vote; +import org.rulez.demokracia.pdengine.votecast.CastVote; + +public class ComputedVoteTestBase { + + @InjectMocks + protected ComputedVoteServiceImpl computedVoteService; + + @Mock + protected BeatTableService beatTableService; + + @Mock + protected BeatTableTransitiveClosureService beatTableTransitiveClosureService; + + @Mock + protected VoteResultComposer voteResultComposer; + + @Mock + protected TallyService tallyService; + + protected ComputedVote computedVote; + + protected Vote vote; + + @Before + public void setUp() { + when(beatTableService.initializeBeatTable(any())) + .thenReturn(createNewBeatTableWithComplexData()); + final List keys = List.of("A", "B", "C", "D"); + when(beatTableService.normalize(any())) + .thenReturn(createTransitiveClosedBeatTable(keys)); + when(beatTableTransitiveClosureService.computeTransitiveClosure(any())) + .thenReturn(createTransitiveClosedBeatTable(keys)); + when(voteResultComposer.composeResult(any())) + .thenReturn(VoteResultTestHelper.createVoteResults()); + when(tallyService.calculateTally(anyString(), any())) + .then(a -> new Tally((String) a.getArgument(0))); + + vote = new Vote( + "name", new ArrayList<>(), List.of("hun", "ger", "eng"), false, 1 + ); + vote.setVotesCast( + List.of(new CastVote(RandomUtils.createRandomKey(), List.of())) + ); + computedVote = computedVoteService.computeVote(vote); + } +} From 5955a92fda5824a5979d2b3ef57993ae968b9820 Mon Sep 17 00:00:00 2001 From: Tamas Szirbucz Date: Fri, 3 May 2019 15:51:02 +0200 Subject: [PATCH 05/38] Make Tally child of BaseEntity. --- .../java/org/rulez/demokracia/pdengine/tally/Tally.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/rulez/demokracia/pdengine/tally/Tally.java b/src/main/java/org/rulez/demokracia/pdengine/tally/Tally.java index f9a785c6..e86a0a7e 100644 --- a/src/main/java/org/rulez/demokracia/pdengine/tally/Tally.java +++ b/src/main/java/org/rulez/demokracia/pdengine/tally/Tally.java @@ -2,13 +2,17 @@ import javax.persistence.Entity; +import org.rulez.demokracia.pdengine.persistence.BaseEntity; + import lombok.Getter; import lombok.Setter; @Getter @Setter @Entity -public class Tally { +public class Tally extends BaseEntity { + + private static final long serialVersionUID = 1L; private String assurance; From 43171ea3ad10b2261ee48d3fa531b317f8fb618e Mon Sep 17 00:00:00 2001 From: Mag Date: Wed, 8 May 2019 19:42:10 +0100 Subject: [PATCH 06/38] object in metamodel, and examples in Schulze method --- engine.zenta | 190 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 173 insertions(+), 17 deletions(-) diff --git a/engine.zenta b/engine.zenta index 8e7daafb..64db4cbf 100644 --- a/engine.zenta +++ b/engine.zenta @@ -818,17 +818,7 @@ a and b are choices of a vote - - A type containing relevant information of a cast vote - -The recorded vote looks something like this: -class CastVote { -String proxyId; -String voteIdentifier; -List <RankedChoice> preferences; -} - - + by getPair(Choice a, Choice b) @@ -862,19 +852,21 @@ output: List<CastVote> result - + + - + + @@ -885,13 +877,15 @@ output: List<CastVote> result + - + + - + @@ -957,6 +951,52 @@ output: List<CastVote> result + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + i is a winner if for each j m[i,j] beats m[j,i] @@ -1024,6 +1064,55 @@ updates the matrix in place + + The BeatTable is a matrix containing pairs of integers. +in BeatTable m; +m[a][b][0] is related to the number of beats candidate a beats candidate b, or the beat path weight related to the same +m[a][b][1] is the same but for b beating a + +a and b are choices of a vote + + + + + + + + A list of choices + + + + + + + + + + A type containing relevant information of a cast vote + +The recorded vote looks something like this: +class CastVote { +String proxyId; +String voteIdentifier; +List <RankedChoice> preferences; +} + + + + + + + + + + + + + + + + + @@ -1948,10 +2037,13 @@ A way to fullfill this objective is to use a hardware-based entropy daemon, e.g. - + + + + @@ -1963,9 +2055,27 @@ A way to fullfill this objective is to use a hardware-based entropy daemon, e.g. + + + + + + + + + + + + + + + + + + - + A well-defined behaviour performed by the application, and the related application interface. The function is atomic: only a single transaction. @@ -2014,6 +2124,52 @@ The function is atomic: only a single transaction. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 68cc06268b074e91161f5581dc58140403d8a9b8 Mon Sep 17 00:00:00 2001 From: Mag Date: Wed, 15 May 2019 07:51:59 +0100 Subject: [PATCH 07/38] first tab at model generation --- docbook.local.xslt | 24 +- engine.zenta | 702 +++++++++++++++++++++++++--------- extract_actual_structure.xslt | 120 ++++++ pom.xml | 3 +- replace.xslt | 31 ++ tools/code2model | 5 + 6 files changed, 700 insertions(+), 185 deletions(-) create mode 100644 extract_actual_structure.xslt create mode 100644 replace.xslt create mode 100755 tools/code2model diff --git a/docbook.local.xslt b/docbook.local.xslt index de29c83f..6ad050a3 100644 --- a/docbook.local.xslt +++ b/docbook.local.xslt @@ -58,11 +58,25 @@ $atleast,$atmost)" /> It - + + + + + have parameter as + + + is the type of parameter in + + + + + + + diff --git a/engine.zenta b/engine.zenta index 64db4cbf..8e93bf75 100644 --- a/engine.zenta +++ b/engine.zenta @@ -1,4 +1,4 @@ - + @@ -6,7 +6,7 @@ A new vote appears in the database, with needed- and countedAssurances, isPrivate, vote id, creation time (unix time), minEndorsements and admin key. - + POST /vote (String votename, List<String> neededAssurances, List<String> countedAssurances, bool isPrivate, int minEndorsements =0, updatable ) -> VoteAdminInfo VoteAdminInfo has @@ -80,7 +80,7 @@ canView: False; users can view the vote result - + PUT /vote/<voteId>/<adminKey> (String votename )-> VoteAdminInfo @@ -132,7 +132,7 @@ String votename: for length and characters contained - + DEL /vote/<voteId>/<adminKey> ->OK @@ -185,7 +185,7 @@ String adminKey: same as vote's adminKey - + PUT /voteparameters/<voteId> (String adminKey, Int minEndorsements, bool canAddin, bool canEndorse, bool canVote, bool canView) -> "OK" @@ -253,7 +253,7 @@ does not contain adminKey - + GET /vote/<voteId> -> JSON vote An example json: @@ -311,7 +311,7 @@ String adminKey: same as vote's adminKey for private votes, "anon" for - + POST /choice/<voteId>/<adminKey> (String choice) -> String choiceId @@ -366,7 +366,7 @@ String choice: the name of the choice - + PUT /choice/<voteId>/<choiceId>/<adminKey> ( String choice) -> "OK" @@ -405,7 +405,7 @@ String choice: the name of the choice - + DEL /choice/<voteId>/<choiceId>/<adminKey> -> "OK" @@ -447,7 +447,7 @@ String choice: the name of the choice - + GET /ballot/<voteId>/<adminKey> -> string ballotId @@ -516,7 +516,7 @@ String choice: the name of the choice - + POST /endorse/<voteId>/<choiceId>/<adminKey> (String userName) -> "OK" @@ -553,7 +553,7 @@ String choice: the name of the choice - + POST /castvote/<voteId>/<ballotId>(List<RankedChoice> rankedChoices) -> vote receipt RankedChoice properties: @@ -674,7 +674,7 @@ rankedChoices have a list of properly formatted RankedChoice instances, where: - + @@ -730,7 +730,7 @@ The TSF shall provide random numbers that meet [ output sequences are cryptograp - + getWsUsername() and hasAssurance(String role) @@ -743,7 +743,7 @@ The TSF shall provide random numbers that meet [ output sequences are cryptograp DBSessionManager is a singleton, and the only interface for closing database connection. DBSessionManager is not intended to be called from any other place than VoteManager. - + A type representing a persisted user identity. It is backing wsContext. @@ -751,7 +751,7 @@ It is backing wsContext. - + @@ -808,7 +808,7 @@ It is backing wsContext. - + The BeatTable is a matrix containing pairs of integers. in BeatTable m; m[a][b][0] is related to the number of beats candidate a beats candidate b, or the beat path weight related to the same @@ -818,7 +818,7 @@ a and b are choices of a vote - + by getPair(Choice a, Choice b) @@ -840,7 +840,7 @@ where direction is either DIRECTION_FORWARD or DIRECTION_BACKWARD The CastVote actually stores the proxy ID for the voter, and consults the voter's User entity - + input: List<CastVote> castVotes output: List<CastVote> result @@ -852,7 +852,7 @@ output: List<CastVote> result - + @@ -861,7 +861,7 @@ output: List<CastVote> result - + @@ -954,49 +954,42 @@ output: List<CastVote> result - - + - - - - - - - - - - - - - - - + - - - - + - + + + + + + + + + + + + i is a winner if for each j m[i,j] beats m[j,i] @@ -1035,36 +1028,36 @@ m[b,a][backward] contains the number of votes cast where b beats a - + input: BeatTable m, List<Choice> ignoredChoices output: List<Choice> winners - + inputs: Pair beat1, Pair beat2 - - + + input: List<CastVote> castVotes output: a BeatTable For any given pair of elements ij and ji , at most one is initialized to something other than (0,0): the one that contains a larger value in m. That element is initialized to a reference to a pair containing the larger and the smaller of the two values. Thus, diagonal elements are initialized to (0,0); if m_ij=m_ji, both are initialized to (0,0). - + input: BeatTable m output: List<List<Choice>> winnerlist - + input: BeatTable matrix updates the matrix in place - + The BeatTable is a matrix containing pairs of integers. in BeatTable m; m[a][b][0] is related to the number of beats candidate a beats candidate b, or the beat path weight related to the same @@ -1073,21 +1066,22 @@ m[a][b][1] is the same but for b beating a a and b are choices of a vote - - - - - + + + + + A list of choices +List<Choice> - - - - - - - + + + + + + + A type containing relevant information of a cast vote The recorded vote looks something like this: @@ -1098,21 +1092,29 @@ List <RankedChoice> preferences; } - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -1244,7 +1246,7 @@ the beatpath matrix computation does not affect the initial beat matrix (done on if any - + GET /vote/<voteId>/results/new (String adminKey) see https://github.com/andrewcmyers/civs/blob/master/cgi-bin/beatpath2.pm for a Schulze implementation @@ -1324,7 +1326,7 @@ as a property of the Result object - + GET /vote/<voteId>/results -> voteresultJSON. The result contains for each assurances: - the list of candidates with id, rank, the beat ratio for the next candidate(s), for the first whether it is Condorcet winner @@ -1368,7 +1370,7 @@ The result contains for each assurances: - + @@ -1399,13 +1401,15 @@ The result contains for each assurances: - + Updates the assurances of all users using the appropriate ADA Web Service + + @@ -1467,9 +1471,9 @@ The result contains for each assurances: - - - + + + @@ -1498,10 +1502,17 @@ The result contains for each assurances: + + + + + + + - - - + + + @@ -1510,6 +1521,8 @@ The result contains for each assurances: see https://github.com/andrewcmyers/civs/blob/master/cgi-bin/beatpath2.pm for a Schulze implementation + + @@ -1653,7 +1666,7 @@ The result contains for each assurances: - + This is an exception. It is thrown to signal a condition where the request cannot be fulfilled because the business logic does not allow it. It have a message describing the problem, and a list of String arguments which can add additional informations (e.g. the objects which have problems. The point is that the outer interface can distinguish between error branches of the business logic and internal errors, and communicate to the caller accordingly. @@ -1664,6 +1677,235 @@ The point is that the outer interface can distinguish between error branches of + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1720,9 +1962,9 @@ The point is that the outer interface can distinguish between error branches of - – Individual verifiability: a voter can check that her own ballot is included in the -election’s bulletin board. -– Universal verifiability: anyone can check that the election outcome corresponds to + – Individual verifiability: a voter can check that her own ballot is included in the +election’s bulletin board. +– Universal verifiability: anyone can check that the election outcome corresponds to the ballots published on the bulletin board. https://bensmyth.com/files/Smyth10-definition-verifiability.LNCS.pdf @@ -1732,7 +1974,7 @@ https://bensmyth.com/files/Smyth10-definition-verifiability.LNCS.pdf - + @@ -2037,13 +2279,10 @@ A way to fullfill this objective is to use a hardware-based entropy daemon, e.g. - + - - - - + @@ -2052,30 +2291,54 @@ A way to fullfill this objective is to use a hardware-based entropy daemon, e.g. - + - - - - + + + + - - + + + + + + + + + + + + - - + + + + + + + + + + + + - - + + - - + + + + + + - + A well-defined behaviour performed by the application, and the related application interface. The function is atomic: only a single transaction. @@ -2108,7 +2371,7 @@ The function is atomic: only a single transaction. - + @@ -2124,30 +2387,60 @@ The function is atomic: only a single transaction. - - - + + + - + + - + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + @@ -2155,19 +2448,57 @@ The function is atomic: only a single transaction. - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + - + - + + + + + + + + + @@ -2202,39 +2533,44 @@ The function is atomic: only a single transaction. - + - + - + + + - + + + + - + - + - + - + @@ -2244,6 +2580,14 @@ The function is atomic: only a single transaction. + + + + + + + + @@ -2908,7 +3252,7 @@ The function is atomic: only a single transaction. - + @@ -2918,7 +3262,7 @@ The function is atomic: only a single transaction. - + @@ -2960,38 +3304,38 @@ The function is atomic: only a single transaction. - + - - - - - + + + + + - - + + - + - - - - + + + + @@ -3005,9 +3349,9 @@ The function is atomic: only a single transaction. - - - + + + @@ -3039,7 +3383,7 @@ The function is atomic: only a single transaction. - + @@ -3049,9 +3393,9 @@ The function is atomic: only a single transaction. - - - + + + @@ -3061,27 +3405,27 @@ The function is atomic: only a single transaction. - + - - + + - - + + - - - + + + - - - + + + @@ -3090,29 +3434,29 @@ The function is atomic: only a single transaction. - + - - - - - - - - + + + + + + + + - - + + - - + + - + diff --git a/extract_actual_structure.xslt b/extract_actual_structure.xslt new file mode 100644 index 00000000..a96a92ba --- /dev/null +++ b/extract_actual_structure.xslt @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + service + object + class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pom.xml b/pom.xml index c6d74090..401457a5 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.rulez.demokracia PDEngine - 0.0.1-refactor_spring-refactor.9bf0afd + 0.0.1-feature_object_in_metamodel.8527e0e war PDEngine @@ -216,6 +216,7 @@ production-javadoc + private com.github.markusbernhardt.xmldoclet.XmlDoclet -d ${project.build.directory}/production -filename javadoc.xml diff --git a/replace.xslt b/replace.xslt new file mode 100644 index 00000000..c977f22c --- /dev/null +++ b/replace.xslt @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/code2model b/tools/code2model new file mode 100755 index 00000000..39628779 --- /dev/null +++ b/tools/code2model @@ -0,0 +1,5 @@ +#!/bin/bash +set -xe +mkdir -p target +zenta-xslt-runner -xsl:extract_actual_structure.xslt -s:target/production/javadoc.xml >target/code_model.xml +zenta-xslt-runner -xsl:replace.xslt -s:engine.zenta -o:engineout.zenta containerId=folder_generated_structure datafile=target/code_model.xml From b874d674a169196b95310a2932c062250b414e57 Mon Sep 17 00:00:00 2001 From: Mag Date: Wed, 15 May 2019 12:27:27 +0100 Subject: [PATCH 08/38] fields, parameters and returns can be of generic type --- engine.zenta | 1228 ++++++++++++++++++++++++++++++++- extract_actual_structure.xslt | 122 +++- 2 files changed, 1306 insertions(+), 44 deletions(-) diff --git a/engine.zenta b/engine.zenta index 8e93bf75..6712e578 100644 --- a/engine.zenta +++ b/engine.zenta @@ -1408,8 +1408,971 @@ The result contains for each assurances: - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1906,6 +2869,257 @@ The point is that the outer interface can distinguish between error branches of + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2294,11 +3508,8 @@ A way to fullfill this objective is to use a hardware-based entropy daemon, e.g. - + - - - @@ -2320,11 +3531,12 @@ A way to fullfill this objective is to use a hardware-based entropy daemon, e.g. - + + @@ -2394,9 +3606,9 @@ The function is atomic: only a single transaction. - + - + diff --git a/extract_actual_structure.xslt b/extract_actual_structure.xslt index a96a92ba..a4fe3fd2 100644 --- a/extract_actual_structure.xslt +++ b/extract_actual_structure.xslt @@ -20,13 +20,30 @@ + + + + + + + + + + + + + + + + + - + @@ -58,9 +75,13 @@ source="{$id}" target="{$dependent}"/> - - - + + + + + + + @@ -73,29 +94,6 @@ - - - - - - - - - - - - - - - - - - - @@ -106,15 +104,67 @@ - + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - From df4a6f6c838894480f8b5651b0ab5a06536eddf5 Mon Sep 17 00:00:00 2001 From: Mag Date: Thu, 16 May 2019 21:11:00 +0100 Subject: [PATCH 09/38] views, document generation hack --- docbook.local.xslt | 12 +- engine.zenta | 4784 ++++++++++++++++++++-------- engineout.zenta.bak | 5475 +++++++++++++++++++++++++++++++++ extract_actual_structure.xslt | 1 - pom.xml | 2 +- 5 files changed, 8940 insertions(+), 1334 deletions(-) create mode 100644 engineout.zenta.bak diff --git a/docbook.local.xslt b/docbook.local.xslt index 6ad050a3..455a6a41 100644 --- a/docbook.local.xslt +++ b/docbook.local.xslt @@ -61,7 +61,7 @@ $atleast,$atmost)" /> - + have parameter as @@ -69,6 +69,16 @@ $atleast,$atmost)" /> + + + + have field as + + + is the type of field in + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - see https://github.com/andrewcmyers/civs/blob/master/cgi-bin/beatpath2.pm for a Schulze implementation - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + see https://github.com/andrewcmyers/civs/blob/master/cgi-bin/beatpath2.pm for a Schulze implementation + + + @@ -2675,9 +1710,7 @@ The point is that the outer interface can distinguish between error branches of - - @@ -2869,257 +1902,6 @@ The point is that the outer interface can distinguish between error branches of - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -4801,5 +3583,3345 @@ The function is atomic: only a single transaction. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/engineout.zenta.bak b/engineout.zenta.bak new file mode 100644 index 00000000..da4fe297 --- /dev/null +++ b/engineout.zenta.bak @@ -0,0 +1,5475 @@ + + + + + + + A new vote appears in the database, with needed- and countedAssurances, isPrivate, vote id, creation time (unix time), minEndorsements and admin key. + + + POST /vote (String votename, List<String> neededAssurances, List<String> countedAssurances, bool isPrivate, int minEndorsements =0, updatable ) -> VoteAdminInfo + +VoteAdminInfo has +voteId: String +adminKey: String + + + + String votename: for length and characters contained +List<String> neededAssurances: for length and characters contained. no empty string. can be empty. no two strings are the same +List<String> countedAssurances: for length and characters contained. can be empty string. no two strings are the same. nonempty +bool private: true or false + + + + + The fields describing what can be done with the vote are the following: +canAddIn: False ;users can add in without the adminKey +canEndorse: False ;users can endorse choices +canVote: False; users can vote +canView: False; users can view the vote result + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + the following vote parameters are invariant: +- vote id +- admin key +- needed assurances +- counted assurances +- is private +- creation time + + + + + PUT /vote/<voteId>/<adminKey> (String votename )-> VoteAdminInfo + + + No other vote parameters are changed + + + String voteId: id of existing vote +String adminKey: same as vote's adminKey +String votename: for length and characters contained + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DEL /vote/<voteId>/<adminKey> ->OK + + + String voteId: id of existing vote +String adminKey: same as vote's adminKey + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PUT /voteparameters/<voteId> (String adminKey, Int minEndorsements, bool canAddin, bool canEndorse, bool canVote, bool canView) -> "OK" + + + + String voteId: id of existing vote +String adminKey: same as vote's adminKey +Int minEndorsements: 0<= x =< 2 147 483 647 +bool canAddin: true or false +bool canEndorse: true or false +bool canVote: true or false +bool canView: true or false + +PUT /voteparameters/<voteId> (String adminKey, Int minEndorsements, bool canAddin, bool canEndorse, bool canVote, bool canView) -> "OK" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + containing +- the vote id and name, +- id, name and endorsement count for all choices, +- the needed assurances +- the counted assurances +- whether the vote is private +- all vote parameters +- creation date +- number of votes cast +- if canView, the vote results + +does not contain adminKey + + + + + GET /vote/<voteId> -> JSON vote + +An example json: + +{"name": "vote name", +"canAddIn": true, +"creationTime": 1488796118, +"choices": [ + {"initiator": "user1", "endorsers": ["user2", "user3", "user4", "user5"], "name": "choice 1", "id": "id_choice_1"}, + {"initiator": "user2", "endorsers": ["user1", "user4", "user5"], "name": "choice 2", "id": "id_choice_2"}, + {"initiator": null, "endorsers": [], "name": "The below choices are not acceptable", "id": "id_choice_3"}] +"canEndorse": true, +"countedAssurances": ["", "magyar"], +"neededAssurances": ["magyar"], +"isPrivate": true, +"minEndorsements": 3, +"id": "vote_id", +"canView": true, +"canVote": true} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + String voteId: id of existing vote +String adminKey: same as vote's adminKey for private votes, "anon" for public ones + + + + + POST /choice/<voteId>/<adminKey> (String choice) -> String choiceId + + + + If no user, then None is registered + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + String voteId: id of existing vote +String adminKey: same as vote's adminKey, or "user" +String choice: the name of the choice + + + + + + + + PUT /choice/<voteId>/<choiceId>/<adminKey> ( String choice) -> "OK" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DEL /choice/<voteId>/<choiceId>/<adminKey> -> "OK" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + GET /ballot/<voteId>/<adminKey> -> string ballotId + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if the user tries to obtain a second ballot, an exception is thrown + + + + + + + + + POST /endorse/<voteId>/<choiceId>/<adminKey> (String userName) -> "OK" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + POST /castvote/<voteId>/<ballotId>(List<RankedChoice> rankedChoices) -> vote receipt + +RankedChoice properties: +String choiceId +int rank + + + + + + + + String voteId: id of existing vote +String ballotId: id of existing ballot +rankedChoices have a list of properly formatted RankedChoice instances, where: + choiceId is the id of an existing choice + rank is nonnegative integer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + After casting a vote, a secret random identifier of it is shown to the user, and shown in the tally with the vote cast + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + See https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Zertifizierung/Interpretationen/AIS_20_AIS_31_Evaluation_of_random_number_generators_e.pdf?__blob=publicationFile + +FCS_RNG.1.1 +The TSF shall provide a [physical] random number generator that meet [with the statistical random number generator tests specified in FIPS 140-2, Security Requirements for Cryptographic Modules, section 4.9.1] . +FCS_RNG.1.2 +The TSF shall provide random numbers that meet [ output sequences are cryptographically strong, as described in RFC 1750: Randomness Recommendations for Security. ]. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + getWsUsername() and hasAssurance(String role) + + + + IVoteManager.getVoteManager(wsContext); + + + VoteManager calls DBSessionManager in constructor time. +DBSessionManager is a singleton, and the only interface for closing database connection. +DBSessionManager is not intended to be called from any other place than VoteManager. + + + A type representing a persisted user identity. +It is backing wsContext. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The BeatTable is a matrix containing pairs of integers. +in BeatTable m; +m[a][b][0] is related to the number of beats candidate a beats candidate b, or the beat path weight related to the same +m[a][b][1] is the same but for b beating a + +a and b are choices of a vote + + + + + + by getPair(Choice a, Choice b) + + + by beatInformation(Choice a,Choice b, Direction direction) +where direction is either DIRECTION_FORWARD or DIRECTION_BACKWARD + + + + by setPair(Choice a, Choice b, Pair pair) + + + + by List<RankedChoice> getPreferences() + + + by List<String> getAssurances() + +The CastVote actually stores the proxy ID for the voter, and consults the voter's User entity + + + + input: List<CastVote> castVotes +output: List<CastVote> result + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + i is a winner if for each j m[i,j] beats m[j,i] + + + + if beat1[forward] > beat2[forward] then beat1 wins, and vica versa + + + + if beat1[forward] = beat2[forward] and beat1[backward] > beat2[backward] then beat2 wins, and vica versa + + + + for each i, j, k + m[i,j] = max(m[i,j], min(m[i,k],m[k,j]) +where max and min uses compareBeats for comparison + + + + + m[a,b][forward] contains the number of votes casts where a beats b +m[b,a][backward] contains the number of votes cast where b beats a + + + + + if votes(a) > votes(b) then m[b,a] = (0,0) + + + + m[a,b][backward] = n where n is the number of votes cast where b beats a + + + m[a,b][forward] = n where n is the number of votes cast where a beats b + + + + + input: BeatTable m, List<Choice> ignoredChoices +output: List<Choice> winners + + + + + inputs: Pair beat1, Pair beat2 + + + + + input: List<CastVote> castVotes +output: a BeatTable + +For any given pair of elements ij and ji , at most one is initialized to something other than (0,0): the one that contains a larger value in m. That element is initialized to a reference to a pair containing the larger and the smaller of the two values. Thus, diagonal elements are initialized to (0,0); if m_ij=m_ji, both are initialized to (0,0). + + + + input: BeatTable m +output: List<List<Choice>> winnerlist + + + + input: BeatTable matrix +updates the matrix in place + + + + + The BeatTable is a matrix containing pairs of integers. +in BeatTable m; +m[a][b][0] is related to the number of beats candidate a beats candidate b, or the beat path weight related to the same +m[a][b][1] is the same but for b beating a + +a and b are choices of a vote + + + + + + + + A list of choices +List<Choice> + + + + + + + + + + A type containing relevant information of a cast vote + +The recorded vote looks something like this: +class CastVote { +String proxyId; +String voteIdentifier; +List <RankedChoice> preferences; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + by normalizing the initial beat matrix, and doing transitive closure +the beatpath matrix computation does not affect the initial beat matrix (done on a copy) + + + + + + + + + + + for each winner (but the first one) the beat ratio to the previous ones is given + + + + for each winner (but the first one) the beat ratio to the first one(s) is given + + + if any + + + + GET /vote/<voteId>/results/new (String adminKey) + +see https://github.com/andrewcmyers/civs/blob/master/cgi-bin/beatpath2.pm for a Schulze implementation + + + + using a timestamp service defined in the context parameter "timestampService". +if no such context parameter is given, fallback to https://freetsa.org/tsr + + + + official result is timestamped + + + adminkey is "user" in this case +if all the following hold: +- they have all the neededAssurances +- canVote is true +- canView is true +- no result is computed in the last hour + + + + in UTC +as a property of the Result object + + + + so there is a Result object, with the resultJson property storing the result, and the timeStamp property storing the timestamp (or null) + + + + + empty string assurance represents "no assurance" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + an official result is one with a timestamp + + + + + GET /vote/<voteId>/results -> voteresultJSON. +The result contains for each assurances: +- the list of candidates with id, rank, the beat ratio for the next candidate(s), for the first whether it is Condorcet winner +- the two tables used in Schulze method +- additional statistics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Updates the assurances of all users using the appropriate ADA Web Service + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + see https://github.com/andrewcmyers/civs/blob/master/cgi-bin/beatpath2.pm for a Schulze implementation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The following rules apply: + + + + + + + + + This is an exception. It is thrown to signal a condition where the request cannot be fulfilled because the business logic does not allow it. +It have a message describing the problem, and a list of String arguments which can add additional informations (e.g. the objects which have problems. +The point is that the outer interface can distinguish between error branches of the business logic and internal errors, and communicate to the caller accordingly. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + – Individual verifiability: a voter can check that her own ballot is included in the +election’s bulletin board. +– Universal verifiability: anyone can check that the election outcome corresponds to +the ballots published on the bulletin board. +https://bensmyth.com/files/Smyth10-definition-verifiability.LNCS.pdf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Implementation details: + +The application uses the NativePRNGBlocking secure random implementation, +which in turn uses /dev/random. +A way to fullfill this objective is to use a hardware-based entropy daemon, e.g. haveged. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A well-defined behaviour performed by the application, and the related application interface. +The function is atomic: only a single transaction. + + + + + + + + A testable aspect of function: a set of pre- and postconditions. + + + + + + + + Describes a set of behaviours in the business level + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/extract_actual_structure.xslt b/extract_actual_structure.xslt index a4fe3fd2..385e8a8b 100644 --- a/extract_actual_structure.xslt +++ b/extract_actual_structure.xslt @@ -80,7 +80,6 @@ - diff --git a/pom.xml b/pom.xml index 401457a5..c9121242 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.rulez.demokracia PDEngine - 0.0.1-feature_object_in_metamodel.8527e0e + 0.0.1-feature_object_in_metamodel.b874d67 war PDEngine From a1a2188fbabb52072d8e88bf68cd85214b01c53d Mon Sep 17 00:00:00 2001 From: Mag Date: Tue, 4 Jun 2019 12:59:02 +0100 Subject: [PATCH 10/38] modeling --- engine.zenta | 2593 +++++++++++++++++++++----------------------------- 1 file changed, 1062 insertions(+), 1531 deletions(-) diff --git a/engine.zenta b/engine.zenta index 6a682187..db6bb457 100644 --- a/engine.zenta +++ b/engine.zenta @@ -2,655 +2,6 @@ - - - A new vote appears in the database, with needed- and countedAssurances, isPrivate, vote id, creation time (unix time), minEndorsements and admin key. - - - POST /vote (String votename, List<String> neededAssurances, List<String> countedAssurances, bool isPrivate, int minEndorsements =0, updatable ) -> VoteAdminInfo - -VoteAdminInfo has -voteId: String -adminKey: String - - - - String votename: for length and characters contained -List<String> neededAssurances: for length and characters contained. no empty string. can be empty. no two strings are the same -List<String> countedAssurances: for length and characters contained. can be empty string. no two strings are the same. nonempty -bool private: true or false - - - - - The fields describing what can be done with the vote are the following: -canAddIn: False ;users can add in without the adminKey -canEndorse: False ;users can endorse choices -canVote: False; users can vote -canView: False; users can view the vote result - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - the following vote parameters are invariant: -- vote id -- admin key -- needed assurances -- counted assurances -- is private -- creation time - - - - - PUT /vote/<voteId>/<adminKey> (String votename )-> VoteAdminInfo - - - No other vote parameters are changed - - - String voteId: id of existing vote -String adminKey: same as vote's adminKey -String votename: for length and characters contained - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DEL /vote/<voteId>/<adminKey> ->OK - - - String voteId: id of existing vote -String adminKey: same as vote's adminKey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PUT /voteparameters/<voteId> (String adminKey, Int minEndorsements, bool canAddin, bool canEndorse, bool canVote, bool canView) -> "OK" - - - - String voteId: id of existing vote -String adminKey: same as vote's adminKey -Int minEndorsements: 0<= x =< 2 147 483 647 -bool canAddin: true or false -bool canEndorse: true or false -bool canVote: true or false -bool canView: true or false - -PUT /voteparameters/<voteId> (String adminKey, Int minEndorsements, bool canAddin, bool canEndorse, bool canVote, bool canView) -> "OK" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - containing -- the vote id and name, -- id, name and endorsement count for all choices, -- the needed assurances -- the counted assurances -- whether the vote is private -- all vote parameters -- creation date -- number of votes cast -- if canView, the vote results - -does not contain adminKey - - - - - GET /vote/<voteId> -> JSON vote - -An example json: - -{"name": "vote name", -"canAddIn": true, -"creationTime": 1488796118, -"choices": [ - {"initiator": "user1", "endorsers": ["user2", "user3", "user4", "user5"], "name": "choice 1", "id": "id_choice_1"}, - {"initiator": "user2", "endorsers": ["user1", "user4", "user5"], "name": "choice 2", "id": "id_choice_2"}, - {"initiator": null, "endorsers": [], "name": "The below choices are not acceptable", "id": "id_choice_3"}] -"canEndorse": true, -"countedAssurances": ["", "magyar"], -"neededAssurances": ["magyar"], -"isPrivate": true, -"minEndorsements": 3, -"id": "vote_id", -"canView": true, -"canVote": true} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - String voteId: id of existing vote -String adminKey: same as vote's adminKey for private votes, "anon" for public ones - - - - - POST /choice/<voteId>/<adminKey> (String choice) -> String choiceId - - - - If no user, then None is registered - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - String voteId: id of existing vote -String adminKey: same as vote's adminKey, or "user" -String choice: the name of the choice - - - - - - - - PUT /choice/<voteId>/<choiceId>/<adminKey> ( String choice) -> "OK" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DEL /choice/<voteId>/<choiceId>/<adminKey> -> "OK" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GET /ballot/<voteId>/<adminKey> -> string ballotId - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if the user tries to obtain a second ballot, an exception is thrown - - - - - - - - - POST /endorse/<voteId>/<choiceId>/<adminKey> (String userName) -> "OK" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST /castvote/<voteId>/<ballotId>(List<RankedChoice> rankedChoices) -> vote receipt - -RankedChoice properties: -String choiceId -int rank - - - - - - - - String voteId: id of existing vote -String ballotId: id of existing ballot -rankedChoices have a list of properly formatted RankedChoice instances, where: - choiceId is the id of an existing choice - rank is nonnegative integer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - After casting a vote, a secret random identifier of it is shown to the user, and shown in the tally with the vote cast - - - - - - - - @@ -759,9 +110,8 @@ It is backing wsContext. - - + @@ -791,20 +141,13 @@ It is backing wsContext. - - - - - - - - + - + - + @@ -840,88 +183,40 @@ where direction is either DIRECTION_FORWARD or DIRECTION_BACKWARD The CastVote actually stores the proxy ID for the voter, and consults the voter's User entity - - input: List<CastVote> castVotes -output: List<CastVote> result - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + @@ -930,38 +225,36 @@ output: List<CastVote> result - + - + - + - + - + - + - + - + - - - + @@ -984,16 +277,12 @@ output: List<CastVote> result - - - i is a winner if for each j m[i,j] beats m[j,i] - if beat1[forward] > beat2[forward] then beat1 wins, and vica versa @@ -1003,58 +292,21 @@ output: List<CastVote> result if beat1[forward] = beat2[forward] and beat1[backward] > beat2[backward] then beat2 wins, and vica versa - - for each i, j, k - m[i,j] = max(m[i,j], min(m[i,k],m[k,j]) -where max and min uses compareBeats for comparison - - - m[a,b][forward] contains the number of votes casts where a beats b m[b,a][backward] contains the number of votes cast where b beats a - - - - - if votes(a) > votes(b) then m[b,a] = (0,0) m[a,b][backward] = n where n is the number of votes cast where b beats a - - m[a,b][forward] = n where n is the number of votes cast where a beats b - - - - - input: BeatTable m, List<Choice> ignoredChoices -output: List<Choice> winners - - - inputs: Pair beat1, Pair beat2 - - - - - input: List<CastVote> castVotes -output: a BeatTable - -For any given pair of elements ij and ji , at most one is initialized to something other than (0,0): the one that contains a larger value in m. That element is initialized to a reference to a pair containing the larger and the smaller of the two values. Thus, diagonal elements are initialized to (0,0); if m_ij=m_ji, both are initialized to (0,0). input: BeatTable m output: List<List<Choice>> winnerlist - - - - input: BeatTable matrix -updates the matrix in place - @@ -1066,8 +318,6 @@ m[a][b][1] is the same but for b beating a a and b are choices of a vote - - @@ -1075,7 +325,6 @@ a and b are choices of a vote List<Choice> - @@ -1084,228 +333,48 @@ List<Choice> A type containing relevant information of a cast vote -The recorded vote looks something like this: -class CastVote { -String proxyId; -String voteIdentifier; -List <RankedChoice> preferences; -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - by normalizing the initial beat matrix, and doing transitive closure -the beatpath matrix computation does not affect the initial beat matrix (done on a copy) - - - - - - - - - - - for each winner (but the first one) the beat ratio to the previous ones is given - - - - for each winner (but the first one) the beat ratio to the first one(s) is given - - - if any - - - - GET /vote/<voteId>/results/new (String adminKey) - -see https://github.com/andrewcmyers/civs/blob/master/cgi-bin/beatpath2.pm for a Schulze implementation - - - - using a timestamp service defined in the context parameter "timestampService". -if no such context parameter is given, fallback to https://freetsa.org/tsr - - - - official result is timestamped - - - adminkey is "user" in this case -if all the following hold: -- they have all the neededAssurances -- canVote is true -- canView is true -- no result is computed in the last hour - - - - in UTC -as a property of the Result object - - - - so there is a Result object, with the resultJson property storing the result, and the timeStamp property storing the timestamp (or null) - - - - - empty string assurance represents "no assurance" +The recorded vote looks something like this: +class CastVote { +String proxyId; +String voteIdentifier; +List <RankedChoice> preferences; +} - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - @@ -1375,8 +444,6 @@ The result contains for each assurances: - - @@ -1412,40 +479,9 @@ The result contains for each assurances: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1453,26 +489,15 @@ The result contains for each assurances: - - - - - - - - - - - @@ -1512,7 +537,6 @@ The result contains for each assurances: - @@ -1525,57 +549,12 @@ The result contains for each assurances: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1592,13 +571,9 @@ The result contains for each assurances: - - - - @@ -1608,9 +583,6 @@ The result contains for each assurances: - - - @@ -1629,27 +601,11 @@ The result contains for each assurances: - - - - - - - - - - - - - - - - @@ -3164,425 +2120,6 @@ The function is atomic: only a single transaction. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -4126,6 +2663,9 @@ The function is atomic: only a single transaction. + + + @@ -4153,6 +2693,15 @@ The function is atomic: only a single transaction. + + + + + + + + + @@ -4165,6 +2714,14 @@ The function is atomic: only a single transaction. + + i is a winner if for each j m[i,j] beats m[j,i] + + + + + + @@ -4216,15 +2773,36 @@ The function is atomic: only a single transaction. - + + + + + + + + + + + + + + + + + + + + + + - + @@ -4255,10 +2833,151 @@ The function is atomic: only a single transaction. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + by normalizing the initial beat matrix, and doing transitive closure +the beatpath matrix computation does not affect the initial beat matrix (done on a copy) + + + + + + using a timestamp service defined in the context parameter "timestampService". +if no such context parameter is given, fallback to https://freetsa.org/tsr + + + + official result is timestamped + + + + adminkey is "user" in this case +if all the following hold: +- they have all the neededAssurances +- canVote is true +- canView is true +- no result is computed in the last hour + + + + + + + + + in UTC +as a property of the Result object + + + + so there is a Result object, with the resultJson property storing the result, and the timeStamp property storing the timestamp (or null) + + + + empty string assurance represents "no assurance" + + + + for each winner (but the first one) the beat ratio to the previous ones is given + + + + for each winner (but the first one) the beat ratio to the first one(s) is given + + + if any + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4643,7 +3362,6 @@ The function is atomic: only a single transaction. - @@ -4654,6 +3372,10 @@ The function is atomic: only a single transaction. + + + + @@ -4682,7 +3404,7 @@ The function is atomic: only a single transaction. - + @@ -4705,7 +3427,7 @@ The function is atomic: only a single transaction. - + @@ -4720,7 +3442,7 @@ The function is atomic: only a single transaction. - + @@ -4728,7 +3450,7 @@ The function is atomic: only a single transaction. - + @@ -4759,6 +3481,97 @@ The function is atomic: only a single transaction. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4767,6 +3580,54 @@ The function is atomic: only a single transaction. + + + + + + + + + + + + If no user, then None is registered + + + + String voteId: id of existing vote +String adminKey: same as vote's adminKey, or "user" +String choice: the name of the choice + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5000,6 +3861,9 @@ The function is atomic: only a single transaction. + + + @@ -5023,6 +3887,35 @@ The function is atomic: only a single transaction. + + + + + + + + + + + + + + + + containing +- the vote id and name, +- id, name and endorsement count for all choices, +- the needed assurances +- the counted assurances +- whether the vote is private +- all vote parameters +- creation date +- number of votes cast +- if canView, the vote results + +does not contain adminKey + + @@ -5048,13 +3941,298 @@ The function is atomic: only a single transaction. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - @@ -5064,12 +4242,16 @@ The function is atomic: only a single transaction. + + + + - - + + @@ -5078,13 +4260,13 @@ The function is atomic: only a single transaction. - - + + - + @@ -5094,7 +4276,7 @@ The function is atomic: only a single transaction. - + @@ -5134,6 +4316,86 @@ The function is atomic: only a single transaction. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -5144,6 +4406,58 @@ The function is atomic: only a single transaction. + + + A new vote appears in the database, with needed- and countedAssurances, isPrivate, vote id, creation time (unix time), minEndorsements and admin key. + + + String votename: for length and characters contained +List<String> neededAssurances: for length and characters contained. no empty string. can be empty. no two strings are the same +List<String> countedAssurances: for length and characters contained. can be empty string. no two strings are the same. nonempty +bool private: true or false + + + + + The fields describing what can be done with the vote are the following: +canAddIn: False ;users can add in without the adminKey +canEndorse: False ;users can endorse choices +canVote: False; users can vote +canView: False; users can view the vote result + + + + + + No other vote parameters are changed + + + String voteId: id of existing vote +String adminKey: same as vote's adminKey +String votename: for length and characters contained + + + + + + String voteId: id of existing vote +String adminKey: same as vote's adminKey + + + + + + String voteId: id of existing vote +String adminKey: same as vote's adminKey +Int minEndorsements: 0<= x =< 2 147 483 647 +bool canAddin: true or false +bool canEndorse: true or false +bool canVote: true or false +bool canView: true or false + +PUT /voteparameters/<voteId> (String adminKey, Int minEndorsements, bool canAddin, bool canEndorse, bool canVote, bool canView) -> "OK" + + @@ -5330,7 +4644,7 @@ The function is atomic: only a single transaction. - + @@ -5494,19 +4808,24 @@ The function is atomic: only a single transaction. - + + + + + + - + @@ -5522,18 +4841,60 @@ The function is atomic: only a single transaction. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if votes(a) > votes(b) then m[b,a] = (0,0) + + + + m[a,b][forward] = n where n is the number of votes cast where a beats b + + + @@ -5552,10 +4913,20 @@ The function is atomic: only a single transaction. + + + + + + for each i, j, k + m[i,j] = max(m[i,j], min(m[i,k],m[k,j]) +where max and min uses compareBeats for comparison + + @@ -6012,7 +5383,6 @@ The function is atomic: only a single transaction. - @@ -6074,7 +5444,6 @@ The function is atomic: only a single transaction. - @@ -6214,11 +5583,9 @@ The function is atomic: only a single transaction. - - @@ -6412,6 +5779,9 @@ The function is atomic: only a single transaction. + + + @@ -6421,7 +5791,22 @@ The function is atomic: only a single transaction. + + + + + + + + + + + + + + + @@ -6512,6 +5897,15 @@ The function is atomic: only a single transaction. + + + + + + + + + @@ -6546,11 +5940,79 @@ The function is atomic: only a single transaction. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + After casting a vote, a secret random identifier of it is shown to the user, and shown in the tally with the vote cast + + + + + + + + + + + + String voteId: id of existing vote +String ballotId: id of existing ballot +rankedChoices have a list of properly formatted RankedChoice instances, where: + choiceId is the id of an existing choice + rank is nonnegative integer + + + + + + + + + + + + + + @@ -6842,6 +6304,15 @@ The function is atomic: only a single transaction. + + + + + + + + + @@ -6870,10 +6341,69 @@ The function is atomic: only a single transaction. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + if the user tries to obtain a second ballot, an exception is thrown + + + + + + + + String voteId: id of existing vote +String adminKey: same as vote's adminKey for private votes, "anon" for public ones + + + + the following vote parameters are invariant: +- vote id +- admin key +- needed assurances +- counted assurances +- is private +- creation time + + + + + + + + + + @@ -6922,6 +6452,7 @@ The function is atomic: only a single transaction. + From 5389d5febf0c69a2fd5bf250a6b4954705fd9ae6 Mon Sep 17 00:00:00 2001 From: Mag Date: Thu, 6 Jun 2019 09:39:00 +0100 Subject: [PATCH 11/38] deleted unnecessary file --- engineout.zenta.bak | 5475 ------------------------------------------- 1 file changed, 5475 deletions(-) delete mode 100644 engineout.zenta.bak diff --git a/engineout.zenta.bak b/engineout.zenta.bak deleted file mode 100644 index da4fe297..00000000 --- a/engineout.zenta.bak +++ /dev/null @@ -1,5475 +0,0 @@ - - - - - - - A new vote appears in the database, with needed- and countedAssurances, isPrivate, vote id, creation time (unix time), minEndorsements and admin key. - - - POST /vote (String votename, List<String> neededAssurances, List<String> countedAssurances, bool isPrivate, int minEndorsements =0, updatable ) -> VoteAdminInfo - -VoteAdminInfo has -voteId: String -adminKey: String - - - - String votename: for length and characters contained -List<String> neededAssurances: for length and characters contained. no empty string. can be empty. no two strings are the same -List<String> countedAssurances: for length and characters contained. can be empty string. no two strings are the same. nonempty -bool private: true or false - - - - - The fields describing what can be done with the vote are the following: -canAddIn: False ;users can add in without the adminKey -canEndorse: False ;users can endorse choices -canVote: False; users can vote -canView: False; users can view the vote result - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - the following vote parameters are invariant: -- vote id -- admin key -- needed assurances -- counted assurances -- is private -- creation time - - - - - PUT /vote/<voteId>/<adminKey> (String votename )-> VoteAdminInfo - - - No other vote parameters are changed - - - String voteId: id of existing vote -String adminKey: same as vote's adminKey -String votename: for length and characters contained - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DEL /vote/<voteId>/<adminKey> ->OK - - - String voteId: id of existing vote -String adminKey: same as vote's adminKey - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PUT /voteparameters/<voteId> (String adminKey, Int minEndorsements, bool canAddin, bool canEndorse, bool canVote, bool canView) -> "OK" - - - - String voteId: id of existing vote -String adminKey: same as vote's adminKey -Int minEndorsements: 0<= x =< 2 147 483 647 -bool canAddin: true or false -bool canEndorse: true or false -bool canVote: true or false -bool canView: true or false - -PUT /voteparameters/<voteId> (String adminKey, Int minEndorsements, bool canAddin, bool canEndorse, bool canVote, bool canView) -> "OK" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - containing -- the vote id and name, -- id, name and endorsement count for all choices, -- the needed assurances -- the counted assurances -- whether the vote is private -- all vote parameters -- creation date -- number of votes cast -- if canView, the vote results - -does not contain adminKey - - - - - GET /vote/<voteId> -> JSON vote - -An example json: - -{"name": "vote name", -"canAddIn": true, -"creationTime": 1488796118, -"choices": [ - {"initiator": "user1", "endorsers": ["user2", "user3", "user4", "user5"], "name": "choice 1", "id": "id_choice_1"}, - {"initiator": "user2", "endorsers": ["user1", "user4", "user5"], "name": "choice 2", "id": "id_choice_2"}, - {"initiator": null, "endorsers": [], "name": "The below choices are not acceptable", "id": "id_choice_3"}] -"canEndorse": true, -"countedAssurances": ["", "magyar"], -"neededAssurances": ["magyar"], -"isPrivate": true, -"minEndorsements": 3, -"id": "vote_id", -"canView": true, -"canVote": true} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - String voteId: id of existing vote -String adminKey: same as vote's adminKey for private votes, "anon" for public ones - - - - - POST /choice/<voteId>/<adminKey> (String choice) -> String choiceId - - - - If no user, then None is registered - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - String voteId: id of existing vote -String adminKey: same as vote's adminKey, or "user" -String choice: the name of the choice - - - - - - - - PUT /choice/<voteId>/<choiceId>/<adminKey> ( String choice) -> "OK" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DEL /choice/<voteId>/<choiceId>/<adminKey> -> "OK" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - GET /ballot/<voteId>/<adminKey> -> string ballotId - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if the user tries to obtain a second ballot, an exception is thrown - - - - - - - - - POST /endorse/<voteId>/<choiceId>/<adminKey> (String userName) -> "OK" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POST /castvote/<voteId>/<ballotId>(List<RankedChoice> rankedChoices) -> vote receipt - -RankedChoice properties: -String choiceId -int rank - - - - - - - - String voteId: id of existing vote -String ballotId: id of existing ballot -rankedChoices have a list of properly formatted RankedChoice instances, where: - choiceId is the id of an existing choice - rank is nonnegative integer - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - After casting a vote, a secret random identifier of it is shown to the user, and shown in the tally with the vote cast - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - See https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Zertifizierung/Interpretationen/AIS_20_AIS_31_Evaluation_of_random_number_generators_e.pdf?__blob=publicationFile - -FCS_RNG.1.1 -The TSF shall provide a [physical] random number generator that meet [with the statistical random number generator tests specified in FIPS 140-2, Security Requirements for Cryptographic Modules, section 4.9.1] . -FCS_RNG.1.2 -The TSF shall provide random numbers that meet [ output sequences are cryptographically strong, as described in RFC 1750: Randomness Recommendations for Security. ]. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - getWsUsername() and hasAssurance(String role) - - - - IVoteManager.getVoteManager(wsContext); - - - VoteManager calls DBSessionManager in constructor time. -DBSessionManager is a singleton, and the only interface for closing database connection. -DBSessionManager is not intended to be called from any other place than VoteManager. - - - A type representing a persisted user identity. -It is backing wsContext. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The BeatTable is a matrix containing pairs of integers. -in BeatTable m; -m[a][b][0] is related to the number of beats candidate a beats candidate b, or the beat path weight related to the same -m[a][b][1] is the same but for b beating a - -a and b are choices of a vote - - - - - - by getPair(Choice a, Choice b) - - - by beatInformation(Choice a,Choice b, Direction direction) -where direction is either DIRECTION_FORWARD or DIRECTION_BACKWARD - - - - by setPair(Choice a, Choice b, Pair pair) - - - - by List<RankedChoice> getPreferences() - - - by List<String> getAssurances() - -The CastVote actually stores the proxy ID for the voter, and consults the voter's User entity - - - - input: List<CastVote> castVotes -output: List<CastVote> result - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - i is a winner if for each j m[i,j] beats m[j,i] - - - - if beat1[forward] > beat2[forward] then beat1 wins, and vica versa - - - - if beat1[forward] = beat2[forward] and beat1[backward] > beat2[backward] then beat2 wins, and vica versa - - - - for each i, j, k - m[i,j] = max(m[i,j], min(m[i,k],m[k,j]) -where max and min uses compareBeats for comparison - - - - - m[a,b][forward] contains the number of votes casts where a beats b -m[b,a][backward] contains the number of votes cast where b beats a - - - - - if votes(a) > votes(b) then m[b,a] = (0,0) - - - - m[a,b][backward] = n where n is the number of votes cast where b beats a - - - m[a,b][forward] = n where n is the number of votes cast where a beats b - - - - - input: BeatTable m, List<Choice> ignoredChoices -output: List<Choice> winners - - - - - inputs: Pair beat1, Pair beat2 - - - - - input: List<CastVote> castVotes -output: a BeatTable - -For any given pair of elements ij and ji , at most one is initialized to something other than (0,0): the one that contains a larger value in m. That element is initialized to a reference to a pair containing the larger and the smaller of the two values. Thus, diagonal elements are initialized to (0,0); if m_ij=m_ji, both are initialized to (0,0). - - - - input: BeatTable m -output: List<List<Choice>> winnerlist - - - - input: BeatTable matrix -updates the matrix in place - - - - - The BeatTable is a matrix containing pairs of integers. -in BeatTable m; -m[a][b][0] is related to the number of beats candidate a beats candidate b, or the beat path weight related to the same -m[a][b][1] is the same but for b beating a - -a and b are choices of a vote - - - - - - - - A list of choices -List<Choice> - - - - - - - - - - A type containing relevant information of a cast vote - -The recorded vote looks something like this: -class CastVote { -String proxyId; -String voteIdentifier; -List <RankedChoice> preferences; -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - by normalizing the initial beat matrix, and doing transitive closure -the beatpath matrix computation does not affect the initial beat matrix (done on a copy) - - - - - - - - - - - for each winner (but the first one) the beat ratio to the previous ones is given - - - - for each winner (but the first one) the beat ratio to the first one(s) is given - - - if any - - - - GET /vote/<voteId>/results/new (String adminKey) - -see https://github.com/andrewcmyers/civs/blob/master/cgi-bin/beatpath2.pm for a Schulze implementation - - - - using a timestamp service defined in the context parameter "timestampService". -if no such context parameter is given, fallback to https://freetsa.org/tsr - - - - official result is timestamped - - - adminkey is "user" in this case -if all the following hold: -- they have all the neededAssurances -- canVote is true -- canView is true -- no result is computed in the last hour - - - - in UTC -as a property of the Result object - - - - so there is a Result object, with the resultJson property storing the result, and the timeStamp property storing the timestamp (or null) - - - - - empty string assurance represents "no assurance" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - an official result is one with a timestamp - - - - - GET /vote/<voteId>/results -> voteresultJSON. -The result contains for each assurances: -- the list of candidates with id, rank, the beat ratio for the next candidate(s), for the first whether it is Condorcet winner -- the two tables used in Schulze method -- additional statistics - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Updates the assurances of all users using the appropriate ADA Web Service - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - see https://github.com/andrewcmyers/civs/blob/master/cgi-bin/beatpath2.pm for a Schulze implementation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The following rules apply: - - - - - - - - - This is an exception. It is thrown to signal a condition where the request cannot be fulfilled because the business logic does not allow it. -It have a message describing the problem, and a list of String arguments which can add additional informations (e.g. the objects which have problems. -The point is that the outer interface can distinguish between error branches of the business logic and internal errors, and communicate to the caller accordingly. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - – Individual verifiability: a voter can check that her own ballot is included in the -election’s bulletin board. -– Universal verifiability: anyone can check that the election outcome corresponds to -the ballots published on the bulletin board. -https://bensmyth.com/files/Smyth10-definition-verifiability.LNCS.pdf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Implementation details: - -The application uses the NativePRNGBlocking secure random implementation, -which in turn uses /dev/random. -A way to fullfill this objective is to use a hardware-based entropy daemon, e.g. haveged. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - A well-defined behaviour performed by the application, and the related application interface. -The function is atomic: only a single transaction. - - - - - - - - A testable aspect of function: a set of pre- and postconditions. - - - - - - - - Describes a set of behaviours in the business level - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From fb84264178516426345ccadff181c27605498fdb Mon Sep 17 00:00:00 2001 From: Mag Date: Wed, 31 Jul 2019 20:19:16 +0100 Subject: [PATCH 12/38] new Dockerfile, reformat source --- .classpath | 44 +- .project | 1 - .settings/eclipse-java-google-style.xml | 1317 ++++++++++++----- .settings/org.eclipse.wst.common.component | 103 +- ....eclipse.wst.common.project.facet.core.xml | 10 +- Dockerfile | 105 +- docbook.local.xslt | 61 +- etc/m2/settings.xml | 32 +- extract_actual_structure.xslt | 315 ++-- pmd_rules.xml | 52 +- pom.xml | 722 ++++----- replace.xslt | 46 +- .../pdengine/showvote/VoteShowTest.java | 32 +- 13 files changed, 1828 insertions(+), 1012 deletions(-) diff --git a/.classpath b/.classpath index a15b1712..7c133fd3 100644 --- a/.classpath +++ b/.classpath @@ -1,39 +1,47 @@ - + - - + + - + - - - + + + - + - + - + - + - + - - + + - + - - + + - + diff --git a/.project b/.project index 80b0edca..d8834693 100644 --- a/.project +++ b/.project @@ -47,7 +47,6 @@ - org.springframework.ide.eclipse.core.springnature org.eclipse.jem.workbench.JavaEMFNature org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature diff --git a/.settings/eclipse-java-google-style.xml b/.settings/eclipse-java-google-style.xml index 7bb6804e..5e6e653d 100644 --- a/.settings/eclipse-java-google-style.xml +++ b/.settings/eclipse-java-google-style.xml @@ -1,337 +1,986 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 31d2d02a..69a376f5 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,50 +1,59 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index 380a5c34..27353650 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,8 +1,8 @@ - - - - - + + + + + diff --git a/Dockerfile b/Dockerfile index b0311aaa..6f89f0c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,8 @@ RUN apt-get -y upgrade RUN apt-get -y install software-properties-common apt-transport-https RUN apt-add-repository -y ppa:openjdk-r/ppa -RUN until apt-key adv --keyserver keys.gnupg.net --recv 43DB103F31060848; do echo retrying; done + +RUN until apt-key adv --keyserver keyserver.ubuntu.com --recv EF678DA6D5B1436D3972DFD317BE949418BE5D6B; do echo retrying; done RUN echo deb http://repos.demokracia.rulez.org/apt/debian/ master main >/etc/apt/sources.list.d/repos.demokracia.rulez.org.list RUN apt-get update @@ -23,19 +24,105 @@ RUN git clone --branch feature/compile_with_java_11 https://github.com/magwas/xm cd xml-doclet/; mvn install;\ cd .. ; rm -rf xml-doclet -RUN git clone --branch docker/java11 https://github.com/magwas/PDEngine.git;\ +RUN git clone --branch docker/java11 https://github.com/edemo/PDEngine.git;\ rm /dev/random; cp -a /dev/urandom /dev/random;\ cd PDEngine; export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64;\ - make maven;\ + mvn clean install;\ cd .. ; rm -rf PDEngine RUN sed 's/.ALL:ALL./(ALL) NOPASSWD:/' -i /etc/sudoers -RUN wget "http://ftp.halifax.rwth-aachen.de/eclipse//technology/epp/downloads/release/2019-03/R/eclipse-jee-2019-03-R-linux-gtk-x86_64.tar.gz" -O /tmp/eclipse.tar.gz;\ +RUN wget -q "http://ftp.halifax.rwth-aachen.de/eclipse//technology/epp/downloads/release/2019-03/R/eclipse-jee-2019-03-R-linux-gtk-x86_64.tar.gz" -O /tmp/eclipse.tar.gz;\ cd /opt ; tar xzf /tmp/eclipse.tar.gz;\ rm /tmp/eclipse.tar.gz -RUN wget https://projectlombok.org/downloads/lombok.jar -O /tmp/lombok.jar;\ - java -jar /tmp/lombok.jar install /opt/eclipse;\ - rm /tmp/lombok.jar; -RUN /opt/eclipse/eclipse -application org.eclipse.equinox.p2.director -repository https://dl.bintray.com/pmd/pmd-eclipse-plugin/releases/4.2.0.v20190331-1136 -installIUs net.sourceforge.pmd.eclipse.feature.group -noSplash -RUN /opt/eclipse/eclipse -application org.eclipse.equinox.p2.director -repository https://download.springsource.com/release/TOOLS/update/e4.11/ -installIUs org.springsource.sts.ide.feature.group -noSplash +RUN /opt/eclipse/eclipse -application org.eclipse.equinox.p2.director\ + -repository http://download.eclipse.org/cft/1.2.0\ + -repository http://download.eclipse.org/cft/1.2.0/org.eclipse.cft-1.2.0.v201805291812\ + -repository http://download.eclipse.org/eclipse/updates/4.11\ + -repository http://download.eclipse.org/eclipse/updates/4.11/R-4.11-201903070500\ + -repository http://download.eclipse.org/mpc/releases/1.7.7\ + -repository http://download.eclipse.org/releases/2019-03\ + -repository http://download.eclipse.org/releases/2019-03/201903201000\ + -repository http://download.eclipse.org/releases/latest\ + -repository http://download.eclipse.org/usssdk/drops/release/1.2.0\ + -repository http://download.eclipse.org/usssdk/updates/release/latest\ + -repository http://download.eclipse.org/webtools/repository/2019-06\ + -repository http://download.eclipse.org/webtools/repository/latest\ + -repository https://download.eclipse.org/technology/epp/packages/2019-03\ + -repository https://download.eclipse.org/webtools/downloads/drops/R3.14.0/R-3.14.0-20190612230649/repository\ + -repository https://download.springsource.com/release/TOOLS/sts4-language-servers/e4.8\ + -repository https://download.springsource.com/release/TOOLS/sts4/update/4.3.1.RELEASE/e4.11\ + -repository https://download.springsource.com/release/TOOLS/sts4/update/e4.11\ + -repository https://dl.bintray.com/pmd/pmd-eclipse-plugin/releases/4.2.0.v20190331-1136\ + -installIUs net.sourceforge.pmd.eclipse.feature.group\ + -installIUs com.fasterxml.jackson.core.jackson-annotations\ + -installIUs com.fasterxml.jackson.core.jackson-core\ + -installIUs com.fasterxml.jackson.core.jackson-databind\ + -installIUs com.hierynomus.sshj\ + -installIUs com.jcraft.jzlib\ + -installIUs io.projectreactor.reactor-core\ + -installIUs javassist\ + -installIUs javax.ws.rs\ + -installIUs org.aopalliance\ + -installIUs org.dadacoalition.yedit\ + -installIUs org.eclipse.lsp4j.jsonrpc\ + -installIUs org.eclipse.lsp4j\ + -installIUs org.eclipse.tm4e.core\ + -installIUs org.eclipse.tm4e.registry\ + -installIUs org.eclipse.tm4e.ui\ + -installIUs org.eclipse.xtext.xbase.lib\ + -installIUs org.glassfish.hk2.api\ + -installIUs org.glassfish.hk2.locator\ + -installIUs org.glassfish.hk2.osgi-resource-locator\ + -installIUs org.glassfish.hk2.utils\ + -installIUs org.glassfish.jersey.bundles.repackaged.jersey-guava\ + -installIUs org.glassfish.jersey.core.jersey-client\ + -installIUs org.glassfish.jersey.core.jersey-common\ + -installIUs org.jcodings\ + -installIUs org.joni\ + -installIUs org.json\ + -installIUs org.reactivestreams.reactive-streams\ + -installIUs org.springframework.ide.eclipse.beans.ui.live\ + -installIUs org.springframework.ide.eclipse.boot.dash\ + -installIUs org.springframework.ide.eclipse.boot.launch\ + -installIUs org.springframework.ide.eclipse.boot.refactoring\ + -installIUs org.springframework.ide.eclipse.boot.restart\ + -installIUs org.springframework.ide.eclipse.boot.templates\ + -installIUs org.springframework.ide.eclipse.boot.validation\ + -installIUs org.springframework.ide.eclipse.boot.wizard\ + -installIUs org.springframework.ide.eclipse.boot\ + -installIUs org.springframework.ide.eclipse.buildship20\ + -installIUs org.springframework.ide.eclipse.buildship30\ + -installIUs org.springframework.ide.eclipse.editor.support\ + -installIUs org.springframework.ide.eclipse.imports\ + -installIUs org.springframework.ide.eclipse.xml.namespaces\ + -installIUs org.springframework.tooling.boot.ls\ + -installIUs org.springframework.tooling.bosh.ls\ + -installIUs org.springframework.tooling.cloudfoundry.manifest.ls\ + -installIUs org.springframework.tooling.concourse.ls\ + -installIUs org.springframework.tooling.jdt.ls.commons\ + -installIUs org.springframework.tooling.ls.eclipse.commons\ + -installIUs org.springframework.tooling.ls.eclipse.gotosymbol\ + -installIUs org.springsource.ide.eclipse.commons.cloudfoundry.client.v2\ + -installIUs org.springsource.ide.eclipse.commons.core\ + -installIUs org.springsource.ide.eclipse.commons.frameworks.core\ + -installIUs org.springsource.ide.eclipse.commons.frameworks.ui\ + -installIUs org.springsource.ide.eclipse.commons.livexp\ + -installIUs org.springsource.ide.eclipse.commons.quicksearch\ + -installIUs org.springsource.ide.eclipse.commons.ui\ + -installIUs org.yaml.snakeyaml\ + -installIUs org.springframework.tooling.boot.ls\ + -installIUs org.springframework.ide.eclipse.xml.namespaces\ + -installIUs org.springframework.tooling.bosh.ls\ + -installIUs org.springframework.tooling.cloudfoundry.manifest.ls\ + -installIUs org.springframework.tooling.concourse.ls\ + -installIUs org.springsource.ide.eclipse.commons.quicksearch\ + -installIUs org.springframework.ide.eclipse.boot.dash\ + -noSplash +# -installIUs org.eclipse.lsp4e\ +# -installIUs org.springsource.ide.eclipse.commons.jdk\ +RUN wget -q https://vorboss.dl.sourceforge.net/project/pydev/pydev/PyDev%207.2.1/PyDev%207.2.1.zip -O /tmp/pydev.zip;\ + unzip /tmp/pydev.zip -d /opt/eclipse;\ + rm /tmp/pydev.zip +RUN wget -q https://projectlombok.org/downloads/lombok.jar -O /usr/local/lib/lombok.jar;\ + java -jar /usr/local/lib/lombok.jar install /opt/eclipse ENTRYPOINT ["/build/tools/entrypoint"] CMD ["/bin/bash"] diff --git a/docbook.local.xslt b/docbook.local.xslt index 455a6a41..221a1623 100644 --- a/docbook.local.xslt +++ b/docbook.local.xslt @@ -58,35 +58,44 @@ $atleast,$atmost)" /> It - - - - - have parameter as - - - is the type of parameter in - - - - - - - have field as - - - is the type of field in - - - - - + + + have parameter + + as + + + is the type of parameter + + in + + + + + + + have field + + as + + + is the type of field + + in + + + + + - - + + diff --git a/etc/m2/settings.xml b/etc/m2/settings.xml index 04f60579..3f4e6ba0 100644 --- a/etc/m2/settings.xml +++ b/etc/m2/settings.xml @@ -1,20 +1,20 @@ - - org.sonarsource.scanner.maven - - - - sonar - - true - - - - https://sonarqube.com - bf0e1ea9341a539f1a291a85509c010498b43cca - - - + + org.sonarsource.scanner.maven + + + + sonar + + true + + + + https://sonarqube.com + bf0e1ea9341a539f1a291a85509c010498b43cca + + + diff --git a/extract_actual_structure.xslt b/extract_actual_structure.xslt index 385e8a8b..76939174 100644 --- a/extract_actual_structure.xslt +++ b/extract_actual_structure.xslt @@ -1,150 +1,180 @@ - - - - + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - service - object - class - - - - - + + - - - + + + + + + + - - - - - - + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + service + + + object + + + class + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - - - - - + + + + + - - - - - - - - + " /> + + + + + + + + diff --git a/pmd_rules.xml b/pmd_rules.xml index 307ab74f..c9670557 100644 --- a/pmd_rules.xml +++ b/pmd_rules.xml @@ -8,7 +8,7 @@ - + @@ -92,34 +92,36 @@ public interface Matrix - - - - - + + + + + - - - - + + + + - + - - - + + + - 3 - - - + 3 + + + - - - - + + + + diff --git a/pom.xml b/pom.xml index c9121242..36fe5e3c 100644 --- a/pom.xml +++ b/pom.xml @@ -1,276 +1,280 @@ - - 4.0.0 - + + 4.0.0 + org.springframework.boot spring-boot-starter-parent 2.1.4.RELEASE - + - org.rulez.demokracia - PDEngine - 0.0.1-feature_object_in_metamodel.b874d67 - war - - PDEngine - http://maven.apache.org + org.rulez.demokracia + PDEngine + 0.0.1-feature_object_in_metamodel.b874d67 + war + + PDEngine + http://maven.apache.org + + + UTF-8 + 11 + 11 + edemo/PDEngine + + + + + springplugins + Spring Plugins + http://repo.spring.io/plugins-release/ + + - - UTF-8 - 11 - 11 - edemo/PDEngine - - - - - springplugins - Spring Plugins - http://repo.spring.io/plugins-release/ - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 3.0.0 - - - org.apache.maven.plugins - maven-compiler-plugin - - ${maven.compiler.source} - ${maven.compiler.target} - true - true - - -Xlint:all - -Xlint:-processing - - - - - org.pitest - pitest-maven - 1.4.5 - - - XML - HTML - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - -javaagent:${sonar.jacoco.jar}=destfile=${sonar.jacoco.reportPath} - - - - **/*IntegrationTest - - - - - org.apache.maven.plugins - maven-war-plugin - - - org.mortbay.jetty - maven-jetty-plugin - 6.1.10 - - 10 - - - 8080 - 60000 - - - - - - org.apache.maven.plugins - maven-site-plugin - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-integration-test-sources - generate-test-sources - - add-test-source - - - - src/integration-test/java - - - - - add-integration-test-resources - generate-test-resources - - add-test-resource - - - - - src/integration-test/resources - - - - - - - - org.codehaus.mojo - keytool-maven-plugin - 1.5 - - - - generateKeyPair - - generate-resources - - - - src/main/resources/keystore.jks - changeit - changeit - PDEngineKeys - cn=Unknown, ou=Unknown, L=Unknown, ST=Unknown, o=Unknown, c=Unknown - SHA1withRSA - - 100 - RSA - 1024 - - - - - - - - - integration-test + + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 3.0.0 + + + org.apache.maven.plugins + maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + true + true + + -Xlint:all + -Xlint:-processing + + + + + org.pitest + pitest-maven + 1.4.5 + + + XML + HTML + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + -javaagent:${sonar.jacoco.jar}=destfile=${sonar.jacoco.reportPath} + + + + **/*IntegrationTest + + + + + org.apache.maven.plugins + maven-war-plugin + + + org.mortbay.jetty + maven-jetty-plugin + 6.1.10 + + 10 + + + 8080 + 60000 + + + + + + org.apache.maven.plugins + maven-site-plugin + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-integration-test-sources + generate-test-sources + + add-test-source + + + + src/integration-test/java + + + + + add-integration-test-resources + generate-test-resources + + add-test-resource + + + + + src/integration-test/resources + + + + + + + + org.codehaus.mojo + keytool-maven-plugin + 1.5 + + + + generateKeyPair + + generate-resources + + + + src/main/resources/keystore.jks + changeit + changeit + PDEngineKeys + cn=Unknown, ou=Unknown, L=Unknown, ST=Unknown, o=Unknown, + c=Unknown + SHA1withRSA + + 100 + RSA + 1024 + + + + + + + + + integration-test + + + + maven-failsafe-plugin + 2.22.0 + + + + integration-test + verify + + + + + + **/*IntegrationTest + + + + + + + + + - maven-failsafe-plugin - 2.22.0 - - - - integration-test - verify - - - + org.apache.maven.plugins + maven-pmd-plugin - - **/*IntegrationTest - + 25 + true + true + + pmd_rules.xml + - - - - - - - - - - org.apache.maven.plugins - maven-pmd-plugin - - 25 - true - true - - pmd_rules.xml - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.10.4 - - - production-javadoc - - private - com.github.markusbernhardt.xmldoclet.XmlDoclet - -d ${project.build.directory}/production -filename - javadoc.xml - false - - com.github.markusbernhardt - xml-doclet - 1.0.6-SNAPSHOT - - - - javadoc - - - - test-javadoc - - com.github.markusbernhardt.xmldoclet.XmlDoclet - - -d ${project.build.directory}/test - -filename javadoc.xml - - false - - com.github.markusbernhardt - xml-doclet - 1.0.6-SNAPSHOT - - - - test-javadoc - - - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 3.0.0 - - - - - - - - org.apache.maven.plugins - maven-jxr-plugin - 2.3 - - - - - + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.4 + + + production-javadoc + + private + com.github.markusbernhardt.xmldoclet.XmlDoclet + -d ${project.build.directory}/production + -filename + javadoc.xml + false + + com.github.markusbernhardt + xml-doclet + 1.0.6-SNAPSHOT + + + + javadoc + + + + test-javadoc + + com.github.markusbernhardt.xmldoclet.XmlDoclet + + -d ${project.build.directory}/test + -filename javadoc.xml + + false + + com.github.markusbernhardt + xml-doclet + 1.0.6-SNAPSHOT + + + + test-javadoc + + + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 3.0.0 + + + + + + + + org.apache.maven.plugins + maven-jxr-plugin + 2.3 + + + + + org.springframework.boot spring-boot-starter-data-jpa @@ -295,110 +299,110 @@ test - com.h2database - h2 - test + com.h2database + h2 + test - + com.google.guava guava 11.0.2 - - - junit - junit - - - org.apache.commons - commons-lang3 - - - org.hibernate - hibernate-core - - - org.hibernate - hibernate-annotations - 3.5.6-Final - - - hsqldb - hsqldb - 1.8.0.10 - test - - - asm - asm - 3.3.1 - - - org.glassfish.jersey.containers - jersey-container-servlet-core - - - org.glassfish.jersey.core - jersey-client - test - - - org.glassfish.jersey.media - jersey-media-json-jackson - - - org.hsqldb - hsqldb - - - org.eclipse.jetty - jetty-webapp - - - org.eclipse.jetty - jetty-jmx - - - javax.xml.ws - jaxws-api - - - org.springframework.security - spring-security-web - - - org.springframework.security - spring-security-rsa - 1.0.0.RELEASE - - - org.springframework.security - spring-security-config - - - org.slf4j - slf4j-simple - provided - - - org.mockito - mockito-core - - - com.google.code.gson - gson - - - org.junit.jupiter - junit-jupiter-api - test - - - com.github.markusbernhardt - xml-doclet - 1.0.6-SNAPSHOT - - + + + junit + junit + + + org.apache.commons + commons-lang3 + + + org.hibernate + hibernate-core + + + org.hibernate + hibernate-annotations + 3.5.6-Final + + + hsqldb + hsqldb + 1.8.0.10 + test + + + asm + asm + 3.3.1 + + + org.glassfish.jersey.containers + jersey-container-servlet-core + + + org.glassfish.jersey.core + jersey-client + test + + + org.glassfish.jersey.media + jersey-media-json-jackson + + + org.hsqldb + hsqldb + + + org.eclipse.jetty + jetty-webapp + + + org.eclipse.jetty + jetty-jmx + + + javax.xml.ws + jaxws-api + + + org.springframework.security + spring-security-web + + + org.springframework.security + spring-security-rsa + 1.0.0.RELEASE + + + org.springframework.security + spring-security-config + + + org.slf4j + slf4j-simple + provided + + + org.mockito + mockito-core + + + com.google.code.gson + gson + + + org.junit.jupiter + junit-jupiter-api + test + + + com.github.markusbernhardt + xml-doclet + 1.0.6-SNAPSHOT + + diff --git a/replace.xslt b/replace.xslt index c977f22c..caa7b438 100644 --- a/replace.xslt +++ b/replace.xslt @@ -2,30 +2,34 @@ - + - - + + - - - - - + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + diff --git a/src/test/java/org/rulez/demokracia/pdengine/showvote/VoteShowTest.java b/src/test/java/org/rulez/demokracia/pdengine/showvote/VoteShowTest.java index 9c008a04..a27eddb1 100644 --- a/src/test/java/org/rulez/demokracia/pdengine/showvote/VoteShowTest.java +++ b/src/test/java/org/rulez/demokracia/pdengine/showvote/VoteShowTest.java @@ -2,7 +2,9 @@ import static org.junit.Assert.*; import static org.rulez.demokracia.pdengine.showvote.VoteShowAssertUtil.*; + import java.util.Objects; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -10,6 +12,7 @@ import org.rulez.demokracia.pdengine.annotations.TestedBehaviour; import org.rulez.demokracia.pdengine.annotations.TestedFeature; import org.rulez.demokracia.pdengine.annotations.TestedOperation; + import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -40,13 +43,16 @@ public void the_name_attribute_contains_the_name_of_the_vote() { } @Test - public void the_creationTime_attribute_contains_the_creation_time_of_the_vote() { + public void + the_creationTime_attribute_contains_the_creation_time_of_the_vote() { assertEquals(result.get(CREATION_TIME).getAsLong(), vote.getCreationTime()); } @Test public void the_choices_attribute_contains_the_choices_of_the_vote() { - assertEquals(vote.getChoices().size(), result.get(CHOICES).getAsJsonObject().entrySet().size()); + assertEquals( + vote.getChoices().size(), result.get(CHOICES).getAsJsonObject().entrySet().size() + ); } @Test @@ -56,19 +62,27 @@ public void the_initiator_of_the_choice_is_in_the_json() { } @Test - public void the_countedAssurances_attribute_contains_the_counted_assurances_of_the_vote() { + public void + the_countedAssurances_attribute_contains_the_counted_assurances_of_the_vote() { vote.getCountedAssurances().add(COUNTED_ASSURANCE); - final JsonArray jsonCountedAssurances = createJson().get(COUNTED_ASSURANCES).getAsJsonArray(); + final JsonArray jsonCountedAssurances = + createJson().get(COUNTED_ASSURANCES).getAsJsonArray(); - assertJsonContainsAllElement(jsonCountedAssurances, vote.getCountedAssurances()); + assertJsonContainsAllElement( + jsonCountedAssurances, vote.getCountedAssurances() + ); } @Test - public void the_neededAssurances_attribute_contains_the_needed_assurances_of_the_vote() { - final JsonArray jsonNeededAssurances = result.get(NEEDED_ASSURANCES).getAsJsonArray(); - - assertJsonContainsAllElement(jsonNeededAssurances, vote.getNeededAssurances()); + public void + the_neededAssurances_attribute_contains_the_needed_assurances_of_the_vote() { + final JsonArray jsonNeededAssurances = + result.get(NEEDED_ASSURANCES).getAsJsonArray(); + + assertJsonContainsAllElement( + jsonNeededAssurances, vote.getNeededAssurances() + ); } @Test From 19e66cf93752527fbb2560a11308190fc3e748ba Mon Sep 17 00:00:00 2001 From: Mag Date: Thu, 1 Aug 2019 07:26:17 +0100 Subject: [PATCH 13/38] midair --- Makefile | 83 +++-------------------------------- generate_test_cases.xslt | 8 ++-- pom.xml | 2 +- shippable.yml | 8 ++-- tools/check_mergebuild_enable | 38 ---------------- tools/code2model | 5 --- tools/countTestcases | 53 ---------------------- tools/entrypoint | 16 ------- tools/generate_keystore | 21 --------- tools/generate_secret_env | 16 ------- tools/getGithubIssues | 43 ------------------ tools/getbranch | 9 ---- tools/prepare | 16 ------- tools/publish | 7 --- tools/pullanalize | 34 -------------- tools/script | 4 -- tools/setenv | 9 ---- tools/testenv | 2 +- 18 files changed, 15 insertions(+), 359 deletions(-) delete mode 100755 tools/check_mergebuild_enable delete mode 100755 tools/code2model delete mode 100755 tools/countTestcases delete mode 100755 tools/entrypoint delete mode 100755 tools/generate_keystore delete mode 100755 tools/generate_secret_env delete mode 100755 tools/getGithubIssues delete mode 100755 tools/getbranch delete mode 100755 tools/prepare delete mode 100755 tools/publish delete mode 100755 tools/pullanalize delete mode 100755 tools/script delete mode 100644 tools/setenv diff --git a/Makefile b/Makefile index 46836670..e8d10de3 100644 --- a/Makefile +++ b/Makefile @@ -1,79 +1,6 @@ -all: install - -install: compile sonar shippable - cp -rf engine/* target/* shippable - -shippable: - mkdir -p shippable - -sonar: sonarconfig buildreports - ./tools/pullanalize - -sonarconfig: - cp etc/m2/settings.xml ~/.m2 - -compile: zentaworkaround javabuild engine.compiled codedocs - -codedocs: shippable/engine-testcases.xml shippable/engine-implementedBehaviours.xml shippable/engine-implementedBehaviours.html shippable/bugpriorities.xml - -shippable/engine-testcases.xml: engine.richescape shippable - zenta-xslt-runner -xsl:generate_test_cases.xslt -s engine.richescape outputbase=shippable/engine- - -shippable/engine-implementedBehaviours.xml: buildreports shippable - zenta-xslt-runner -xsl:generate-behaviours.xslt -s target/test/javadoc.xml outputbase=shippable/engine- - -CONSISTENCY_INPUTS=shippable/engine-testcases.xml shippable/engine-implementedBehaviours.xml - -include /usr/share/zenta-tools/model.rules - -engine.consistencycheck: engine.rich engine.check $(CONSISTENCY_INPUTS) - zenta-xslt-runner -xsl:xslt/consistencycheck.xslt -s:$(basename $@).check -o:$@ >$(basename $@).consistency.stderr 2>&1 - sed 's/\//:/' <$(basename $@).consistency.stderr |sort --field-separator=':' --key=2 - -testenv: - ./tools/testenv - -javabuild: maven buildreports - touch javabuild - -maven: target/PDEngine-0.0.1-SNAPSHOT.jar javadoc - - -javadoc: - mkdir -p target/production target/test - JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 mvn javadoc:javadoc javadoc:test-javadoc site - -target/PDEngine-0.0.1-SNAPSHOT.jar: maven-prepare keystore maven-build - -maven-prepare: - mvn build-helper:parse-version versions:set versions:commit -DnewVersion=\$${parsedVersion.majorVersion}.\$${parsedVersion.minorVersion}.\$${parsedVersion.incrementalVersion}-$$(tools/getbranch|sed 'sA/A_Ag').$$(git rev-parse --short HEAD) - mvn clean - -maven-build: - mvn org.jacoco:jacoco-maven-plugin:prepare-agent install org.pitest:pitest-maven:mutationCoverage site -Pintegration-test - -buildreports: maven - zenta-xslt-runner -xsl:cpd2pmd.xslt -s:target/pmd.xml -o target/pmd_full.xml - find ~/.m2/repository/org/slf4j/slf4j-api/ -regex .*slf4j-api-[0-9.]*.jar -exec ln -f -s {} /tmp/slf4j-api.jar \; - find ~/.m2/repository/org/slf4j/slf4j-simple/ -regex .*slf4j-simple-[0-9.]*.jar -exec ln -f -s {} /tmp/slf4j-simple.jar \; - java -cp /tmp/slf4j-api.jar:/tmp/slf4j-simple.jar:/usr/local/lib/mutation-analysis-plugin-1.3-SNAPSHOT.jar ch.devcon5.sonar.plugins.mutationanalysis.StandaloneAnalysis - -clean: - git clean -fdx - rm -rf zenta-tools xml-doclet - -inputs/engine.issues.xml: shippable/engine-implementedBehaviours.xml shippable/engine-testcases.xml - mkdir -p inputs - tools/getGithubIssues edemo PDEngine f279765590d25bedfc9f08f7fc39a8c39c891711 >inputs/engine.issues.xml - -zentaworkaround: - mkdir -p ~/.zenta/.metadata/.plugins/org.eclipse.e4.workbench/ - cp workbench.xmi ~/.zenta/.metadata/.plugins/org.eclipse.e4.workbench/ - touch zentaworkaround - -shippable/bugpriorities.xml: engine.consistencycheck inputs/engine.issues.xml engine.richescape shippable - zenta-xslt-runner -xsl:issue-priorities.xslt -s:engine.consistencycheck -o:shippable/bugpriorities.xml issuesfile=inputs/engine.issues.xml modelfile=engine.richescape missingissuefile=shippable/missing.xml - -keystore: - ./tools/generate_keystore +export GITHUB_ORGANIZATION=edemo +export REPO_NAME=PDEngine +MODEL_BASENAME = engine +JAVA_TARGET = PDEngine-0.0.1-SNAPSHOT.jar +include /usr/local/toolchain/rules.make diff --git a/generate_test_cases.xslt b/generate_test_cases.xslt index 5365ffce..d023b2fc 100644 --- a/generate_test_cases.xslt +++ b/generate_test_cases.xslt @@ -63,10 +63,10 @@ select="//element[@xsi:type='Business Function']"> + select="zenta:neighbours(/,$feature,'contains,1')"> + select="zenta:neighbours($root,$operation,'does/is done by,1')"> + select="zenta:neighbours($root,$testcase,'is tested by/tests,2,testcase')"> diff --git a/pom.xml b/pom.xml index 36fe5e3c..270742a1 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.rulez.demokracia PDEngine - 0.0.1-feature_object_in_metamodel.b874d67 + 0.0.1-feature_toolchain.fb84264 war PDEngine diff --git a/shippable.yml b/shippable.yml index 44ad2608..5d806fdb 100644 --- a/shippable.yml +++ b/shippable.yml @@ -1,12 +1,12 @@ -build_image: edemo/pdengine:docker_java11 +build_image: test language: python python: - 2.7 build: ci: - - tools/script + - /usr/local/toolchain/tools/Script on_success: - - tools/publish + - /usr/local/toolchain/tools/publish on_failure: - - tools/publish + - /usr/local/toolchain/tools/publish diff --git a/tools/check_mergebuild_enable b/tools/check_mergebuild_enable deleted file mode 100755 index 9f8fbb29..00000000 --- a/tools/check_mergebuild_enable +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/python3 - -import urllib.request -import os -import sys -import json - -pullrequest=os.environ['PULL_REQUEST'] -commit=os.environ['COMMIT'][:7] -comitter=os.environ['COMMITTER'] -print(dict(pull=pullrequest,commit=commit,comitter=comitter)) -authorized_users= [ - 'magwas', - 'gypeng', - 'utopszkij', -] -if pullrequest == "false": - sys.exit(0) -if comitter in authorized_users: - sys.exit(0) -uri = "https://api.github.com/repos/edemo/PDEngine/issues/{0}/comments".format(pullrequest) -print(uri) -stuff = urllib.request.urlopen(uri).read() -comments=json.loads(stuff.decode('utf-8')) -for comment in comments: - commentuser = comment['user']['login'] - if commentuser in authorized_users: - commentbody = comment['body'] - print("comment from "+commentuser+": "+commentbody) - print("checking for "+commit) - if ("can_build" in commentbody) and (commit in commentbody): - sys.exit(0) - -print("the pull request cannot be built until an authorized user does not comment 'can_build "+commit+"'") -print("authorized users:") -print(authorized_users) -sys.exit(-1) - diff --git a/tools/code2model b/tools/code2model deleted file mode 100755 index 39628779..00000000 --- a/tools/code2model +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -set -xe -mkdir -p target -zenta-xslt-runner -xsl:extract_actual_structure.xslt -s:target/production/javadoc.xml >target/code_model.xml -zenta-xslt-runner -xsl:replace.xslt -s:engine.zenta -o:engineout.zenta containerId=folder_generated_structure datafile=target/code_model.xml diff --git a/tools/countTestcases b/tools/countTestcases deleted file mode 100755 index e5e6cb71..00000000 --- a/tools/countTestcases +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/python - -import sys -import json -import urllib -import re -import argparse - -parser = argparse.ArgumentParser(description="Tool for list dev's completed tasks with implemented test case count.") -parser.add_argument('user', help='Repository owner Github user') -parser.add_argument('repo', help='Name of Github repo') -parser.add_argument('token', help='Access token') -parser.add_argument('developer', help='Github user name of the developer') -parser.add_argument('-l', '--last-billed', help='Last billed pull request number', default=0, type=int) -args = parser.parse_args(); - -def isUser(developer, userToMatch): - return userToMatch is not None and developer == userToMatch['login'] - -def getJSONContent(uri): - request = urllib.urlopen(uri) - return json.loads(request.read() if request.getcode() == 200 else "[]") - -def uriWithToken(uri, token): - return "{0}?access_token={1}".format(uri, token) - -def getTestCaseCountFromComments(uri): - comments = getJSONContent(uri) - for comment in comments: - match = re.match(r".*testcase\w*\s*=\s*(\d+)", comment['body'], re.DOTALL | re.IGNORECASE) - if match is not None: - return match.group(1) - -def getTestcaseCount(commentsUri, reviewsUri, token): - return getTestCaseCountFromComments(uriWithToken(commentsUri, token)) or getTestCaseCountFromComments(uriWithToken(reviewsUri, token)) - -def reviewsUrl(user, repo, pullId): - return "https://api.github.com/repos/{0}/{1}/pulls/{2}/reviews".format(user, repo, pullId); - -def issuesUrl(user, repo, developer, token): - return "https://api.github.com/search/issues?q=user:{0}+repo:{1}+author:{2}+state:closed+type:pr+review:approved&sort=number&order=desc&access_token={3}".format(user, repo, developer, token) - - -print "Description | PR number | Test case count" -sumTests = 0 -issuesUri = issuesUrl(args.user, args.repo, args.developer, args.token) -issues = filter(lambda i: int(i['number']) > args.last_billed, getJSONContent(issuesUri)['items']) -for issue in issues: - testCaseCount = getTestcaseCount(issue['comments_url'], reviewsUrl(args.user, args.repo, issue['number']), args.token) - print "{0} | {1} | {2}".format(issue['title'], issue['number'], testCaseCount) - sumTests += int(testCaseCount or 0) - -print "\nSum Test Cases: ", sumTests diff --git a/tools/entrypoint b/tools/entrypoint deleted file mode 100755 index dd004c5e..00000000 --- a/tools/entrypoint +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -xe - -rm /dev/random -cp -a /dev/urandom /dev/random; -groupadd -g ${DEVGID} developer -useradd -u ${DEVUID} -g ${DEVGID} -G sudo -d /home/developer developer -chown ${DEVUID}:${DEVGID} /home/developer -if [ ! -d /home/developer/.m2 ] -then - cp -r /root/.m2 /home/developer - chown -R developer.developer /home/developer -fi - -export HOME=/home/developer -exec sudo -u developer "$@" diff --git a/tools/generate_keystore b/tools/generate_keystore deleted file mode 100755 index 7426dc26..00000000 --- a/tools/generate_keystore +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -xe -me=$(readlink -f "$0") -pdedir=$(dirname $(dirname "$me")) -KEYSTOREDIR=$pdedir/target/test-classes/resources -KEYSTOREFILE=keystore.pk12 -mkdir -p $KEYSTOREDIR -cd $KEYSTOREDIR || exit 1 -if [ ! -f "$KEYSTOREFILE" ] -then - SUBJ="/C=HU/ST=Pest/L=Hungary/O=Kozossegi Digitalis Eszkozok Alapitvany/OU=Org/CN=*.demokracia.rulez.org" - KEYSTOREPASS="changeit" - ALIAS="PDEngineKeys" - PRIVKEYFILE=selfsigned.key - CERTFILE=selfsigned.crt - openssl req -x509 -newkey rsa:2048 -keyout $PRIVKEYFILE -out $CERTFILE -days 365 -nodes -subj "$SUBJ" - openssl pkcs12 -name "$ALIAS" -export -in $CERTFILE -inkey $PRIVKEYFILE -out $KEYSTOREFILE -passout pass:"$KEYSTOREPASS" - rm $PRIVKEYFILE $CERTFILE - chmod og-r-w-x $KEYSTOREFILE -fi -ls -l $KEYSTOREDIR/$KEYSTOREFILE diff --git a/tools/generate_secret_env b/tools/generate_secret_env deleted file mode 100755 index 817e5306..00000000 --- a/tools/generate_secret_env +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -if [ $# -eq 0 ] -then - echo "usage: $0 " - echo "expects the ssh pubkey at ~/.ssh/shippable..pub" - exit 1 -fi -set -xe -mkdir -p ~/tmp -KEYFILE=etc/secrets/key.$1 -PASSFILE=~/tmp/secret.data -openssl rand 192 -out $PASSFILE -openssl aes-256-cbc -in ~/.ssh/shippable.PDEngine.env -out etc/secrets/shippable.env.$1.encrypted -pass file:$PASSFILE -openssl rsautl -encrypt -pubin -inkey <(ssh-keygen -e -f ~/.ssh/shippable.$1.pub -m PKCS8) -in $PASSFILE -out $KEYFILE -rm -f $PASSFILE diff --git a/tools/getGithubIssues b/tools/getGithubIssues deleted file mode 100755 index bc2a436c..00000000 --- a/tools/getGithubIssues +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/python - -import sys -import json -import urllib -import re - -user=sys.argv[1] -repo=sys.argv[2] -token=sys.argv[3] - -def getLinksFromBody(body): - return re.findall(r"\[(?P[^[]*)\]\((?P[^)]*)",body) - -def printIssue(issue): - print ' '.format( - issue['id'], - issue['state'].encode('utf-8'), - issue['html_url']) - print ' {0}'.format( - issue['title'].encode('utf-8')) - body=issue['body'] - links = getLinksFromBody(body) - for link in links: - print ' '.format( - link[1].encode('utf-8'), - link[0].encode('utf-8')) - print "" - -pageNumber = 1 -print "" -while True: - issuesUri="https://api.github.com/repos/{0}/{1}/issues?state=all&page={2}&access_token={3}".format(user,repo,pageNumber,token) - page = urllib.urlopen(issuesUri) - content = page.read() - issues = json.loads(content) - if len(issues) == 0: - break - for issue in issues: - printIssue(issue) - pageNumber += 1 - -print "" diff --git a/tools/getbranch b/tools/getbranch deleted file mode 100755 index 535187de..00000000 --- a/tools/getbranch +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -a=$(git rev-parse --abbrev-ref HEAD) -if [ $a == HEAD ] -then - echo $BRANCH -else - echo $a -fi - diff --git a/tools/prepare b/tools/prepare deleted file mode 100755 index f89f4492..00000000 --- a/tools/prepare +++ /dev/null @@ -1,16 +0,0 @@ -set -x -export DISPLAY=:0 -if [ -a /tmp/.X11-unix/X0 ] -then - echo skipping X server -else - Xvnc4 -SecurityTypes none -localhost :0 & -fi -#!!!do not do it on a production system!!! -#run haveged instead -sudo rm /dev/random -sudo cp -a /dev/urandom /dev/random -#end of workaround for low entropy level -export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/ -set |sed 's/=[a-z0-9].*/=EXISTS/' -ls -l /usr/lib/jvm/*/bin/java diff --git a/tools/publish b/tools/publish deleted file mode 100755 index efafbd46..00000000 --- a/tools/publish +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -repo=$(git remote -v|grep "origin.*fetch"|sed 'sA^.*github.com/AA;sA/.*AA') -rsync -e "ssh -p 22022" -ar shippable/ shippable@demokracia.rulez.org:/var/www/adadocs/PDEngine/$repo/$BUILD_NUMBER -normalized_branch=$(echo $BRANCH|sed 'sA[/_]A.Ag') -ln -s $BUILD_NUMBER $normalized_branch -rsync -e "ssh -p 22022" -a $normalized_branch shippable@demokracia.rulez.org:/var/www/adadocs/PDEngine/$repo - diff --git a/tools/pullanalize b/tools/pullanalize deleted file mode 100755 index 45a327cc..00000000 --- a/tools/pullanalize +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -set -xe -function normalize_branch_name_for_sonar() { - echo "${1}" |sed 's/[^A-Za-z0-9/.-]/_/g' -} - -echo PULL REQUEST $PULL_REQUEST -BASE_BRANCH=$(normalize_branch_name_for_sonar "${BASE_BRANCH}") -HEAD_BRANCH=$(normalize_branch_name_for_sonar "${HEAD_BRANCH}") -BRANCH=$(normalize_branch_name_for_sonar "${BRANCH}") -if [ $PULL_REQUEST != false ] -then - mvn sonar:sonar -Dsonar.organization=edemo\ - -Dsonar.pullrequest.provider=github\ - -Dsonar.pullrequest.github.repository=${REPO_FULL_NAME} \ - -Dsonar.pullrequest.branch=${HEAD_BRANCH}\ - -Dsonar.pullrequest.key=${PULL_REQUEST}\ - -Dsonar.pullrequest.base=${BASE_BRANCH}\ - -Dsonar.github.oauth=${GITHUB_OAUTH}\ - -Dsonar.github.repository=${REPO_FULL_NAME}\ - -Dsonar.issuesReport.console.enable=true\ - -Dsonar.github.login=magwas\ - -Dsonar.externalIssuesReportPaths=issuesReport.json\ - -Dsonar.java.pmd.reportPaths=target/pmd_full.xml\ - -Dsonar.tests=src/test,src/integration-test\ - -Pintegration-test -else - mvn sonar:sonar -Dsonar.organization=edemo\ - -Dsonar.java.pmd.reportPaths=target/pmd_full.xml\ - -Dsonar.branch.name=${BRANCH}\ - -Dsonar.externalIssuesReportPaths=issuesReport.json\ - -Dsonar.tests=src/test,src/integration-test\ - -Pintegration-test -fi diff --git a/tools/script b/tools/script deleted file mode 100755 index 5cd1944a..00000000 --- a/tools/script +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash -set -xe -. tools/prepare -make diff --git a/tools/setenv b/tools/setenv deleted file mode 100644 index 2a771425..00000000 --- a/tools/setenv +++ /dev/null @@ -1,9 +0,0 @@ -export DISPLAY=:0 -export PATH=$PATH:~/bin -GITUSER=$(git -C /build/ remote -v |grep origin|head -1|sed 's/^.*://;sA/.*AA') -GITCOMMIT=$(git -C /build/ rev-parse HEAD) -export REPO_FULL_NAME=home/$GITUSER -export HEAD_BRANCH=home/$GITUSER -export PULL_REQUEST=$GITCOMMIT -export BASE_BRANCH=develop - diff --git a/tools/testenv b/tools/testenv index d25f3e37..22021c81 100755 --- a/tools/testenv +++ b/tools/testenv @@ -12,7 +12,7 @@ then PORTMAP="" fi -docker run --rm $PORTMAP -e PULL_REQUEST=false -e DEVUID=${DEV_UID} -e DEVGID=${DEV_GID} -e ORG_NAME=local \ +docker run --rm $PORTMAP -e PULL_REQUEST=false -e DEVUID=${DEV_UID} -e DEVGID=${DEV_GID} -e ORG_NAME=local -e issuetoken=${issuetoken} -e sonarkey=${sonarkey}\ -v $(pwd):/build -v ${DEVHOME}:/home/developer -v /tmp/.X11-unix:/tmp/.X11-unix \ -w /build -it ${PDENGINE_IMAGE} From 805f5378361558cd83c16e40995e2bddfeea76ac Mon Sep 17 00:00:00 2001 From: Mag Date: Thu, 1 Aug 2019 10:39:25 +0100 Subject: [PATCH 14/38] builds with kodekonveyor/toolchain image --- .eclipse-pmd | 7 - .pmd | 8 - Makefile | 3 +- cpd2pmd.xslt | 69 -- etc/m2/settings.encrypted.magwas | 0 etc/m2/settings.xml | 20 - extract_actual_structure.xslt | 200 ----- generate-behaviours.xslt | 167 ---- generate_test_cases.xslt | 102 --- issue-priorities.xslt | 99 --- pmd_rules.xml | 142 ---- pom.xml | 4 +- replace.xslt | 35 - shippable.yml | 2 +- workbench.xmi | 1310 ------------------------------ 15 files changed, 5 insertions(+), 2163 deletions(-) delete mode 100644 .eclipse-pmd delete mode 100644 .pmd delete mode 100644 cpd2pmd.xslt delete mode 100644 etc/m2/settings.encrypted.magwas delete mode 100644 etc/m2/settings.xml delete mode 100644 extract_actual_structure.xslt delete mode 100644 generate-behaviours.xslt delete mode 100644 generate_test_cases.xslt delete mode 100644 issue-priorities.xslt delete mode 100644 pmd_rules.xml delete mode 100644 replace.xslt delete mode 100644 workbench.xmi diff --git a/.eclipse-pmd b/.eclipse-pmd deleted file mode 100644 index c7240957..00000000 --- a/.eclipse-pmd +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/.pmd b/.pmd deleted file mode 100644 index 133c62cf..00000000 --- a/.pmd +++ /dev/null @@ -1,8 +0,0 @@ - - - true - pmd_rules.xml - false - true - true - diff --git a/Makefile b/Makefile index e8d10de3..e6851152 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ export GITHUB_ORGANIZATION=edemo +export SONAR_ORG=$(GITHUB_ORGANIZATION) export REPO_NAME=PDEngine MODEL_BASENAME = engine JAVA_TARGET = PDEngine-0.0.1-SNAPSHOT.jar -include /usr/local/toolchain/rules.make +include /usr/local/toolchain/rules.java diff --git a/cpd2pmd.xslt b/cpd2pmd.xslt deleted file mode 100644 index c20b66e0..00000000 --- a/cpd2pmd.xslt +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - Code duplication ( - - lines, - - tokens): - - - - - - - - - - - - - - - - - diff --git a/etc/m2/settings.encrypted.magwas b/etc/m2/settings.encrypted.magwas deleted file mode 100644 index e69de29b..00000000 diff --git a/etc/m2/settings.xml b/etc/m2/settings.xml deleted file mode 100644 index 3f4e6ba0..00000000 --- a/etc/m2/settings.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - org.sonarsource.scanner.maven - - - - sonar - - true - - - - https://sonarqube.com - bf0e1ea9341a539f1a291a85509c010498b43cca - - - - diff --git a/extract_actual_structure.xslt b/extract_actual_structure.xslt deleted file mode 100644 index 76939174..00000000 --- a/extract_actual_structure.xslt +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - service - - - object - - - class - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/generate-behaviours.xslt b/generate-behaviours.xslt deleted file mode 100644 index 029ce470..00000000 --- a/generate-behaviours.xslt +++ /dev/null @@ -1,167 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Implemented behaviours - -
-
- - -
- - - - <xsl:value-of select="$titlestring" /> - - -
-
- - -
- - - <xsl:value-of select="@name" /> - - - - - - -
-
- - - - - - - - - -
- diff --git a/generate_test_cases.xslt b/generate_test_cases.xslt deleted file mode 100644 index d023b2fc..00000000 --- a/generate_test_cases.xslt +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---------------------------------------------------------------------------- - Behaviour: - - @TestedFeature(" - - ") - @TestedOperation(" - - ") - @TestedBehaviour(" - - ") - - @tested_aspect( - - ) - - - - - - - - - - - - - - - - - - - - - - - - . - - - - - - - - - - diff --git a/issue-priorities.xslt b/issue-priorities.xslt deleted file mode 100644 index 551ae65c..00000000 --- a/issue-priorities.xslt +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pmd_rules.xml b/pmd_rules.xml deleted file mode 100644 index c9670557..00000000 --- a/pmd_rules.xml +++ /dev/null @@ -1,142 +0,0 @@ - - - - WAR project PMD rules of Kode Konveyor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Rule Description - - 3 - - - - - - - { - // This is ok... -} -]]> - - - - - - - - - - - - - - - - - - - - - - - - 3 - - - - - - - - - - - diff --git a/pom.xml b/pom.xml index 270742a1..5d84bad5 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.rulez.demokracia PDEngine - 0.0.1-feature_toolchain.fb84264 + 0.0.1-feature_toolchain.19e66cf war PDEngine @@ -207,7 +207,7 @@ true true - pmd_rules.xml + /usr/local/toolchain/pmd_rules.xml
diff --git a/replace.xslt b/replace.xslt deleted file mode 100644 index caa7b438..00000000 --- a/replace.xslt +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/shippable.yml b/shippable.yml index 5d806fdb..81392e9c 100644 --- a/shippable.yml +++ b/shippable.yml @@ -1,4 +1,4 @@ -build_image: test +build_image: kodekonveyor/toolchain language: python python: - 2.7 diff --git a/workbench.xmi b/workbench.xmi deleted file mode 100644 index ef483d4a..00000000 --- a/workbench.xmi +++ /dev/null @@ -1,1310 +0,0 @@ - - - - activeSchemeId:org.rulez.magwas.zenta.editor.keybindings - ModelMigrationProcessor.001 - - - - - - - - topLevel - - - - persp.actionSet:org.rulez.magwas.zenta.templates.actionSet - - - - active - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - View - categoryTag:Help - - - View - categoryTag:General - - - View - categoryTag:Help - - - - org.eclipse.e4.primaryDataStack - EditorStack - - - - - View - categoryTag:Other - active - activeOnClose - - ViewMenu - menuContribution:menu - - - - - - View - categoryTag:Other - - ViewMenu - menuContribution:menu - - - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - View - categoryTag:Other - - - View - categoryTag:General - - - View - categoryTag:Other - - - - Draggable - - - Draggable - - - Draggable - - - toolbarSeparator - - - - toolbarSeparator - - - - stretch - SHOW_RESTORE_MENU - - - - - stretch - - - Draggable - - - Draggable - - - - - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - platform:gtk - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - platform:gtk - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - schemeId:org.eclipse.ui.defaultAcceleratorConfiguration - - - - - - - - - - - - - - - - Editor - - - View - categoryTag:General - - - View - categoryTag:Help - - - View - categoryTag:General - - - View - categoryTag:Help - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:Other - - - View - categoryTag:Other - - - View - categoryTag:Other - - - View - categoryTag:Other - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From f8cc9b5d743a9db4be17e61848cffd914903e7cc Mon Sep 17 00:00:00 2001 From: Mag Date: Thu, 1 Aug 2019 10:45:55 +0100 Subject: [PATCH 15/38] cache .m2 in shippable --- shippable.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shippable.yml b/shippable.yml index 81392e9c..c473f4f3 100644 --- a/shippable.yml +++ b/shippable.yml @@ -4,6 +4,9 @@ python: - 2.7 build: + cache: true + cache_dir_list: + - ~/.m2 ci: - /usr/local/toolchain/tools/Script on_success: From 23b5fab95d5a9a59fd3624aa2369fa0f55a56f14 Mon Sep 17 00:00:00 2001 From: Mag Date: Thu, 1 Aug 2019 12:27:09 +0100 Subject: [PATCH 16/38] fix docker image tag --- shippable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index c473f4f3..fc103df3 100644 --- a/shippable.yml +++ b/shippable.yml @@ -1,4 +1,4 @@ -build_image: kodekonveyor/toolchain +build_image: kodekonveyor/toolchain:master language: python python: - 2.7 From 9f7b51271d4cc18ad4b3372e2afd929e30905a13 Mon Sep 17 00:00:00 2001 From: Mag Date: Thu, 1 Aug 2019 20:34:31 +0100 Subject: [PATCH 17/38] dev/random hack is back --- shippable.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/shippable.yml b/shippable.yml index fc103df3..13c20a0c 100644 --- a/shippable.yml +++ b/shippable.yml @@ -8,6 +8,7 @@ build: cache_dir_list: - ~/.m2 ci: + - rm /dev/random; cp -a /dev/urandom /dev/random - /usr/local/toolchain/tools/Script on_success: - /usr/local/toolchain/tools/publish From 8678545034758228d55ffbece85a139f8ef96012 Mon Sep 17 00:00:00 2001 From: Mag Date: Wed, 28 Aug 2019 18:29:01 +0100 Subject: [PATCH 18/38] added kkpipeline integration --- shippable.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shippable.yml b/shippable.yml index 13c20a0c..0ea404fc 100644 --- a/shippable.yml +++ b/shippable.yml @@ -2,13 +2,16 @@ build_image: kodekonveyor/toolchain:master language: python python: - 2.7 +integrations: + generic: + - integrationName: kkpipeline + build: cache: true cache_dir_list: - ~/.m2 ci: - - rm /dev/random; cp -a /dev/urandom /dev/random - /usr/local/toolchain/tools/Script on_success: - /usr/local/toolchain/tools/publish From 1c0d6c2b9285cfe9a688683126ba375e01a4cacc Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 08:54:07 +0100 Subject: [PATCH 19/38] debug --- pom.xml | 2 +- .../ChoiceDeleteAdminKeyIsUserTest.java | 65 ++++++++++++++----- 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index 5d84bad5..890636f7 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.rulez.demokracia PDEngine - 0.0.1-feature_toolchain.19e66cf + 0.0.1-feature_toolchain.c1b8551 war PDEngine diff --git a/src/test/java/org/rulez/demokracia/pdengine/choice/ChoiceDeleteAdminKeyIsUserTest.java b/src/test/java/org/rulez/demokracia/pdengine/choice/ChoiceDeleteAdminKeyIsUserTest.java index a20adef3..b6cbbd1a 100644 --- a/src/test/java/org/rulez/demokracia/pdengine/choice/ChoiceDeleteAdminKeyIsUserTest.java +++ b/src/test/java/org/rulez/demokracia/pdengine/choice/ChoiceDeleteAdminKeyIsUserTest.java @@ -1,6 +1,7 @@ package org.rulez.demokracia.pdengine.choice; import static org.mockito.Mockito.*; + import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -26,59 +27,93 @@ public class ChoiceDeleteAdminKeyIsUserTest extends ChoiceTestBase { @Override @Before public void setUp() { + System.out.println("setUp"); super.setUp(); + System.out.println("setUp done"); } @TestedBehaviour(IF_USER_IS_USED_AS_ADMIN_KEY) @Test public void if_canAddin_is_false_then_other_users_cannot_delete_choices() { + System.out + .println("if_canAddin_is_false_then_other_users_cannot_delete_choices"); final Choice choiceToDelete = createChoice(TEST_USER_NAME, false); when(authService.getAuthenticatedUserName()).thenReturn(TEST_USER_NAME); - assertThrows(() -> choiceService.deleteChoice(new VoteAdminInfo(vote.getId(), USER), - choiceToDelete.getId())).assertMessageIs("The adminKey is \"user\" but canAddin is false."); + assertThrows( + () -> choiceService.deleteChoice(new VoteAdminInfo(vote.getId(), USER), + choiceToDelete.getId() + ) + ).assertMessageIs("The adminKey is \"user\" but canAddin is false."); } @TestedBehaviour(IF_USER_IS_USED_AS_ADMIN_KEY) @Test - public void if_adminKey_is_user_and_the_user_is_not_the_one_who_added_the_choice_then_the_choice_cannot_be_deleted() { + public void + if_adminKey_is_user_and_the_user_is_not_the_one_who_added_the_choice_then_the_choice_cannot_be_deleted() { + System.out.println( + "if_adminKey_is_user_and_the_user_is_not_the_one_who_added_the_choice_then_the_choice_cannot_be_deleted" + ); final Choice choiceToDelete = createChoice(USER, true); - assertThrows(() -> choiceService.deleteChoice(new VoteAdminInfo(vote.getId(), USER), - choiceToDelete.getId())).assertMessageIs( - "The adminKey is \"user\" but the user is not same with that user who added the choice."); + assertThrows( + () -> choiceService.deleteChoice(new VoteAdminInfo(vote.getId(), USER), + choiceToDelete.getId() + ) + ).assertMessageIs( + "The adminKey is \"user\" but the user is not same with that user who added the choice." + ); } @TestedBehaviour(IF_USER_IS_USED_AS_ADMIN_KEY) @Test - public void if_adminKey_is_user_and_canAddin_is_true_then_the_user_who_added_the_choice_is_able_to_delete_it() { + public void + if_adminKey_is_user_and_canAddin_is_true_then_the_user_who_added_the_choice_is_able_to_delete_it() { + System.out.println( + "if_adminKey_is_user_and_canAddin_is_true_then_the_user_who_added_the_choice_is_able_to_delete_it" + ); final Choice choiceToDelete = createChoice(TEST_USER_NAME, true); when(authService.getAuthenticatedUserName()).thenReturn(TEST_USER_NAME); - choiceService.deleteChoice(new VoteAdminInfo(vote.getId(), USER), choiceToDelete.getId()); + choiceService.deleteChoice( + new VoteAdminInfo(vote.getId(), USER), choiceToDelete.getId() + ); - assertThrows(() -> choiceService.getChoice(vote.getId(), choiceToDelete.getId())) + assertThrows( + () -> choiceService.getChoice(vote.getId(), choiceToDelete.getId()) + ) .assertMessageIs("Illegal choiceId"); } @TestedBehaviour(IF_USER_IS_USED_AS_ADMIN_KEY) @Test public void deleteChoice_saves_vote_if_the_choice_is_deleted() { + System.out.println("deleteChoice_saves_vote_if_the_choice_is_deleted"); final Choice choiceToDelete = createChoice(TEST_USER_NAME, true); when(authService.getAuthenticatedUserName()).thenReturn(TEST_USER_NAME); - choiceService.deleteChoice(new VoteAdminInfo(vote.getId(), USER), choiceToDelete.getId()); + choiceService.deleteChoice( + new VoteAdminInfo(vote.getId(), USER), choiceToDelete.getId() + ); verify(voteService).saveVote(vote); } @TestedBehaviour(IF_THE_VOTE_HAS_BALLOTS_ISSUED) @Test - public void if_the_vote_has_issued_ballots_then_the_choice_cannot_be_deleted() { + public void + if_the_vote_has_issued_ballots_then_the_choice_cannot_be_deleted() { + System.out.println( + "if_the_vote_has_issued_ballots_then_the_choice_cannot_be_deleted" + ); final Choice choiceToDelete = createChoice(TEST_USER_NAME, true); vote.getBallots().add("TestBallot"); - assertThrows(() -> choiceService - .deleteChoice(new VoteAdminInfo(vote.getId(), vote.getAdminKey()), choiceToDelete.getId())) - .assertMessageIs("Vote modification disallowed: ballots already issued"); + assertThrows( + () -> choiceService + .deleteChoice(new VoteAdminInfo(vote.getId(), vote.getAdminKey()), choiceToDelete.getId()) + ) + .assertMessageIs("Vote modification disallowed: ballots already issued"); } - private Choice createChoice(final String userName, final boolean isAddinable) { + private Choice + createChoice(final String userName, final boolean isAddinable) { + System.out.println("createChoice"); vote.getParameters().setAddinable(isAddinable); final Choice choiceToDelete = new Choice(CHOICE1, userName); vote.addChoice(choiceToDelete); From 2db02541fa48da346d27951dc24144e9c7f6c4ca Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 09:02:51 +0100 Subject: [PATCH 20/38] debug --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index e6851152..0a518973 100644 --- a/Makefile +++ b/Makefile @@ -5,3 +5,6 @@ MODEL_BASENAME = engine JAVA_TARGET = PDEngine-0.0.1-SNAPSHOT.jar include /usr/local/toolchain/rules.java +maven-build: + mvn --debug org.jacoco:jacoco-maven-plugin:prepare-agent install org.pitest:pitest-maven:mutationCoverage site -Pintegration-test + From bcc25b3e112ce836c330dc97e266b56eab9c261b Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 09:38:28 +0100 Subject: [PATCH 21/38] entropy --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0a518973..c1fd1ce3 100644 --- a/Makefile +++ b/Makefile @@ -6,5 +6,5 @@ JAVA_TARGET = PDEngine-0.0.1-SNAPSHOT.jar include /usr/local/toolchain/rules.java maven-build: - mvn --debug org.jacoco:jacoco-maven-plugin:prepare-agent install org.pitest:pitest-maven:mutationCoverage site -Pintegration-test + rm /dev/random; cp -a /dev/urandom /dev/random;mvn --debug org.jacoco:jacoco-maven-plugin:prepare-agent install org.pitest:pitest-maven:mutationCoverage site -Pintegration-test From 2500cbbe9875b4c8d93e5d34d51a153ff4c38378 Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 10:02:13 +0100 Subject: [PATCH 22/38] sonar org --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c1fd1ce3..d5b24ab4 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ export GITHUB_ORGANIZATION=edemo -export SONAR_ORG=$(GITHUB_ORGANIZATION) +export SONAR_ORG=edemo export REPO_NAME=PDEngine MODEL_BASENAME = engine JAVA_TARGET = PDEngine-0.0.1-SNAPSHOT.jar From 747c0ebb9848f21242e2d74462f726ef93140022 Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 10:19:42 +0100 Subject: [PATCH 23/38] debug --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d5b24ab4..2f40319f 100644 --- a/Makefile +++ b/Makefile @@ -6,5 +6,5 @@ JAVA_TARGET = PDEngine-0.0.1-SNAPSHOT.jar include /usr/local/toolchain/rules.java maven-build: - rm /dev/random; cp -a /dev/urandom /dev/random;mvn --debug org.jacoco:jacoco-maven-plugin:prepare-agent install org.pitest:pitest-maven:mutationCoverage site -Pintegration-test + rm /dev/random; cp -a /dev/urandom /dev/random;echo sonarkey:$$sonarkey|sed 's/[0-9]/X/g'; mvn org.jacoco:jacoco-maven-plugin:prepare-agent install org.pitest:pitest-maven:mutationCoverage site -Pintegration-test From 2dc172e2a0f60793c6ab1faf46d23f6fcd4639d7 Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 10:21:40 +0100 Subject: [PATCH 24/38] debug --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2f40319f..0533e4d5 100644 --- a/Makefile +++ b/Makefile @@ -6,5 +6,5 @@ JAVA_TARGET = PDEngine-0.0.1-SNAPSHOT.jar include /usr/local/toolchain/rules.java maven-build: - rm /dev/random; cp -a /dev/urandom /dev/random;echo sonarkey:$$sonarkey|sed 's/[0-9]/X/g'; mvn org.jacoco:jacoco-maven-plugin:prepare-agent install org.pitest:pitest-maven:mutationCoverage site -Pintegration-test + rm /dev/random; cp -a /dev/urandom /dev/random;set|sed 's/[0-9]/X/g'; mvn org.jacoco:jacoco-maven-plugin:prepare-agent install org.pitest:pitest-maven:mutationCoverage site -Pintegration-test From b19923f6126018ed6c2190388ea4f7297a6f4224 Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 10:29:45 +0100 Subject: [PATCH 25/38] debug --- shippable.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/shippable.yml b/shippable.yml index 0ea404fc..9661906d 100644 --- a/shippable.yml +++ b/shippable.yml @@ -12,6 +12,9 @@ build: cache_dir_list: - ~/.m2 ci: + - export issuetoken + - export sonarkey + - set |sed 's/[0-9]/X/g' - /usr/local/toolchain/tools/Script on_success: - /usr/local/toolchain/tools/publish From c9495ddf89d9c04f61c4b706c4d9c5b25629c36b Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 13:06:34 +0100 Subject: [PATCH 26/38] entropy, publish tests on shippable, required pom elements --- Makefile | 11 +++++++++-- pom.xml | 22 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 0533e4d5..11abecd1 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,15 @@ export SONAR_ORG=edemo export REPO_NAME=PDEngine MODEL_BASENAME = engine JAVA_TARGET = PDEngine-0.0.1-SNAPSHOT.jar +BEFORE_MAVEN = entropy +BEFORE_SONAR = publish_tests include /usr/local/toolchain/rules.java -maven-build: - rm /dev/random; cp -a /dev/urandom /dev/random;set|sed 's/[0-9]/X/g'; mvn org.jacoco:jacoco-maven-plugin:prepare-agent install org.pitest:pitest-maven:mutationCoverage site -Pintegration-test +entropy: + rm /dev/random; cp -a /dev/urandom /dev/random;set|sed 's/[0-9]/X/g' +publish_tests: + mvn org.jacoco:jacoco-maven-plugin:report + cp -r target/site/jacoco shippable/codecoverage + mkdir -p shippable/testresults + mv target/surefire-reports/*.xml shippable/testresults diff --git a/pom.xml b/pom.xml index 890636f7..7c732d55 100644 --- a/pom.xml +++ b/pom.xml @@ -12,11 +12,31 @@ org.rulez.demokracia PDEngine - 0.0.1-feature_toolchain.c1b8551 + 0.0.1-feature_toolchain.2db0254 war PDEngine http://maven.apache.org + A voting engine + + + GNU GPL v3 or any later + https://www.gnu.org/licenses/gpl-3.0.en.html + + + + + Community Digital Tools Foundation + info@adatom.hu + Community Digital Tools Foundation + https://e.demokracia.rules.org/ + + + + scm:git:git://github.com/edemo/PDEngine.git + scm:git:ssh://github.com:edemo/PDEngine.git + http://github.com/edemo/PDEngine/tree/master + UTF-8 From c207529c0f1e3abb249384ba235f76ae139ccf0e Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 13:18:07 +0100 Subject: [PATCH 27/38] fixup --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 11abecd1..06050263 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,9 @@ export SONAR_ORG=edemo export REPO_NAME=PDEngine MODEL_BASENAME = engine JAVA_TARGET = PDEngine-0.0.1-SNAPSHOT.jar -BEFORE_MAVEN = entropy +BEFORE_MAVEN_BUILD = entropy BEFORE_SONAR = publish_tests + include /usr/local/toolchain/rules.java entropy: From 68974acb7ce7a9eff78952d40319c44d457f1b42 Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 13:21:15 +0100 Subject: [PATCH 28/38] rewound debugs --- pom.xml | 2 +- shippable.yml | 3 - .../ChoiceDeleteAdminKeyIsUserTest.java | 65 +++++-------------- 3 files changed, 16 insertions(+), 54 deletions(-) diff --git a/pom.xml b/pom.xml index 7c732d55..f0387b31 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.rulez.demokracia PDEngine - 0.0.1-feature_toolchain.2db0254 + 0.0.1-feature_toolchain.c9495dd war PDEngine diff --git a/shippable.yml b/shippable.yml index 9661906d..0ea404fc 100644 --- a/shippable.yml +++ b/shippable.yml @@ -12,9 +12,6 @@ build: cache_dir_list: - ~/.m2 ci: - - export issuetoken - - export sonarkey - - set |sed 's/[0-9]/X/g' - /usr/local/toolchain/tools/Script on_success: - /usr/local/toolchain/tools/publish diff --git a/src/test/java/org/rulez/demokracia/pdengine/choice/ChoiceDeleteAdminKeyIsUserTest.java b/src/test/java/org/rulez/demokracia/pdengine/choice/ChoiceDeleteAdminKeyIsUserTest.java index b6cbbd1a..a20adef3 100644 --- a/src/test/java/org/rulez/demokracia/pdengine/choice/ChoiceDeleteAdminKeyIsUserTest.java +++ b/src/test/java/org/rulez/demokracia/pdengine/choice/ChoiceDeleteAdminKeyIsUserTest.java @@ -1,7 +1,6 @@ package org.rulez.demokracia.pdengine.choice; import static org.mockito.Mockito.*; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -27,93 +26,59 @@ public class ChoiceDeleteAdminKeyIsUserTest extends ChoiceTestBase { @Override @Before public void setUp() { - System.out.println("setUp"); super.setUp(); - System.out.println("setUp done"); } @TestedBehaviour(IF_USER_IS_USED_AS_ADMIN_KEY) @Test public void if_canAddin_is_false_then_other_users_cannot_delete_choices() { - System.out - .println("if_canAddin_is_false_then_other_users_cannot_delete_choices"); final Choice choiceToDelete = createChoice(TEST_USER_NAME, false); when(authService.getAuthenticatedUserName()).thenReturn(TEST_USER_NAME); - assertThrows( - () -> choiceService.deleteChoice(new VoteAdminInfo(vote.getId(), USER), - choiceToDelete.getId() - ) - ).assertMessageIs("The adminKey is \"user\" but canAddin is false."); + assertThrows(() -> choiceService.deleteChoice(new VoteAdminInfo(vote.getId(), USER), + choiceToDelete.getId())).assertMessageIs("The adminKey is \"user\" but canAddin is false."); } @TestedBehaviour(IF_USER_IS_USED_AS_ADMIN_KEY) @Test - public void - if_adminKey_is_user_and_the_user_is_not_the_one_who_added_the_choice_then_the_choice_cannot_be_deleted() { - System.out.println( - "if_adminKey_is_user_and_the_user_is_not_the_one_who_added_the_choice_then_the_choice_cannot_be_deleted" - ); + public void if_adminKey_is_user_and_the_user_is_not_the_one_who_added_the_choice_then_the_choice_cannot_be_deleted() { final Choice choiceToDelete = createChoice(USER, true); - assertThrows( - () -> choiceService.deleteChoice(new VoteAdminInfo(vote.getId(), USER), - choiceToDelete.getId() - ) - ).assertMessageIs( - "The adminKey is \"user\" but the user is not same with that user who added the choice." - ); + assertThrows(() -> choiceService.deleteChoice(new VoteAdminInfo(vote.getId(), USER), + choiceToDelete.getId())).assertMessageIs( + "The adminKey is \"user\" but the user is not same with that user who added the choice."); } @TestedBehaviour(IF_USER_IS_USED_AS_ADMIN_KEY) @Test - public void - if_adminKey_is_user_and_canAddin_is_true_then_the_user_who_added_the_choice_is_able_to_delete_it() { - System.out.println( - "if_adminKey_is_user_and_canAddin_is_true_then_the_user_who_added_the_choice_is_able_to_delete_it" - ); + public void if_adminKey_is_user_and_canAddin_is_true_then_the_user_who_added_the_choice_is_able_to_delete_it() { final Choice choiceToDelete = createChoice(TEST_USER_NAME, true); when(authService.getAuthenticatedUserName()).thenReturn(TEST_USER_NAME); - choiceService.deleteChoice( - new VoteAdminInfo(vote.getId(), USER), choiceToDelete.getId() - ); + choiceService.deleteChoice(new VoteAdminInfo(vote.getId(), USER), choiceToDelete.getId()); - assertThrows( - () -> choiceService.getChoice(vote.getId(), choiceToDelete.getId()) - ) + assertThrows(() -> choiceService.getChoice(vote.getId(), choiceToDelete.getId())) .assertMessageIs("Illegal choiceId"); } @TestedBehaviour(IF_USER_IS_USED_AS_ADMIN_KEY) @Test public void deleteChoice_saves_vote_if_the_choice_is_deleted() { - System.out.println("deleteChoice_saves_vote_if_the_choice_is_deleted"); final Choice choiceToDelete = createChoice(TEST_USER_NAME, true); when(authService.getAuthenticatedUserName()).thenReturn(TEST_USER_NAME); - choiceService.deleteChoice( - new VoteAdminInfo(vote.getId(), USER), choiceToDelete.getId() - ); + choiceService.deleteChoice(new VoteAdminInfo(vote.getId(), USER), choiceToDelete.getId()); verify(voteService).saveVote(vote); } @TestedBehaviour(IF_THE_VOTE_HAS_BALLOTS_ISSUED) @Test - public void - if_the_vote_has_issued_ballots_then_the_choice_cannot_be_deleted() { - System.out.println( - "if_the_vote_has_issued_ballots_then_the_choice_cannot_be_deleted" - ); + public void if_the_vote_has_issued_ballots_then_the_choice_cannot_be_deleted() { final Choice choiceToDelete = createChoice(TEST_USER_NAME, true); vote.getBallots().add("TestBallot"); - assertThrows( - () -> choiceService - .deleteChoice(new VoteAdminInfo(vote.getId(), vote.getAdminKey()), choiceToDelete.getId()) - ) - .assertMessageIs("Vote modification disallowed: ballots already issued"); + assertThrows(() -> choiceService + .deleteChoice(new VoteAdminInfo(vote.getId(), vote.getAdminKey()), choiceToDelete.getId())) + .assertMessageIs("Vote modification disallowed: ballots already issued"); } - private Choice - createChoice(final String userName, final boolean isAddinable) { - System.out.println("createChoice"); + private Choice createChoice(final String userName, final boolean isAddinable) { vote.getParameters().setAddinable(isAddinable); final Choice choiceToDelete = new Choice(CHOICE1, userName); vote.addChoice(choiceToDelete); From 08109dc6af34a350af21d487a629989ef6749a54 Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 13:23:27 +0100 Subject: [PATCH 29/38] more debug rewind --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 06050263..f1a9d6b9 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ BEFORE_SONAR = publish_tests include /usr/local/toolchain/rules.java entropy: - rm /dev/random; cp -a /dev/urandom /dev/random;set|sed 's/[0-9]/X/g' + rm /dev/random; cp -a /dev/urandom /dev/random publish_tests: mvn org.jacoco:jacoco-maven-plugin:report From 3a3f509a4191d0d0e48af72fe29dcd9d7e4a9b04 Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 13:30:36 +0100 Subject: [PATCH 30/38] integration envvars --- shippable.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shippable.yml b/shippable.yml index 0ea404fc..3466a45d 100644 --- a/shippable.yml +++ b/shippable.yml @@ -12,6 +12,8 @@ build: cache_dir_list: - ~/.m2 ci: + - export issuetoken + - export sonarkey - /usr/local/toolchain/tools/Script on_success: - /usr/local/toolchain/tools/publish From 41ab01981c7d7319292621605f21d9c204b89990 Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 13:48:13 +0100 Subject: [PATCH 31/38] debug again... --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f1a9d6b9..229ee94e 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ BEFORE_SONAR = publish_tests include /usr/local/toolchain/rules.java entropy: - rm /dev/random; cp -a /dev/urandom /dev/random + rm /dev/random; cp -a /dev/urandom /dev/random; set |sed 's/[0-9]/X/g' publish_tests: mvn org.jacoco:jacoco-maven-plugin:report From 1cfe5acda8798b76aa2b70ddb9ec50ae25030580 Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 13:50:09 +0100 Subject: [PATCH 32/38] envvars still --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 229ee94e..e789d84e 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,8 @@ MODEL_BASENAME = engine JAVA_TARGET = PDEngine-0.0.1-SNAPSHOT.jar BEFORE_MAVEN_BUILD = entropy BEFORE_SONAR = publish_tests +export issuetoken +export sonarkey include /usr/local/toolchain/rules.java From 079b047ca407f07fd1f0e2aee9197165f5c5628f Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 14:04:06 +0100 Subject: [PATCH 33/38] fixup --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e789d84e..6297967e 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ export GITHUB_ORGANIZATION=edemo export SONAR_ORG=edemo export REPO_NAME=PDEngine +export issuetoken=$(issuetoken) +export sonarkey=$(sonarkey) MODEL_BASENAME = engine JAVA_TARGET = PDEngine-0.0.1-SNAPSHOT.jar BEFORE_MAVEN_BUILD = entropy BEFORE_SONAR = publish_tests -export issuetoken -export sonarkey include /usr/local/toolchain/rules.java From 0146b03cd330612e35516f85e62121501efb2a00 Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 14:10:45 +0100 Subject: [PATCH 34/38] fixup --- Makefile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Makefile b/Makefile index 6297967e..229ee94e 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,6 @@ export GITHUB_ORGANIZATION=edemo export SONAR_ORG=edemo export REPO_NAME=PDEngine -export issuetoken=$(issuetoken) -export sonarkey=$(sonarkey) MODEL_BASENAME = engine JAVA_TARGET = PDEngine-0.0.1-SNAPSHOT.jar BEFORE_MAVEN_BUILD = entropy From d767d2b7776ee42aafbb0fe6249a322c9018f854 Mon Sep 17 00:00:00 2001 From: Mag Date: Mon, 2 Sep 2019 14:29:08 +0100 Subject: [PATCH 35/38] more debug --- shippable.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shippable.yml b/shippable.yml index 3466a45d..a2288103 100644 --- a/shippable.yml +++ b/shippable.yml @@ -12,8 +12,7 @@ build: cache_dir_list: - ~/.m2 ci: - - export issuetoken - - export sonarkey + - set |sed 's/[0-9]/X/g' - /usr/local/toolchain/tools/Script on_success: - /usr/local/toolchain/tools/publish From fd80524e665efbc331db542c7b5ae79f59a60584 Mon Sep 17 00:00:00 2001 From: Mag Date: Sat, 14 Sep 2019 01:13:42 +0100 Subject: [PATCH 36/38] removed a debug, shippable hook button clicked --- shippable.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/shippable.yml b/shippable.yml index a2288103..c41147df 100644 --- a/shippable.yml +++ b/shippable.yml @@ -1,7 +1,4 @@ build_image: kodekonveyor/toolchain:master -language: python -python: - - 2.7 integrations: generic: - integrationName: kkpipeline @@ -12,7 +9,6 @@ build: cache_dir_list: - ~/.m2 ci: - - set |sed 's/[0-9]/X/g' - /usr/local/toolchain/tools/Script on_success: - /usr/local/toolchain/tools/publish From df64d2b202f7ee81b1d0f8d10d04c5c8f6da0256 Mon Sep 17 00:00:00 2001 From: Mag Date: Sat, 14 Sep 2019 01:42:06 +0100 Subject: [PATCH 37/38] debug --- shippable.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/shippable.yml b/shippable.yml index c41147df..622c100e 100644 --- a/shippable.yml +++ b/shippable.yml @@ -9,6 +9,7 @@ build: cache_dir_list: - ~/.m2 ci: + - set |sed 's/[0-9]/X/g' - /usr/local/toolchain/tools/Script on_success: - /usr/local/toolchain/tools/publish From 62e2a3e203a44a75b01dea7b41fe31d395275b99 Mon Sep 17 00:00:00 2001 From: Mag Date: Sat, 14 Sep 2019 01:49:05 +0100 Subject: [PATCH 38/38] trigger build --- pom.xml | 2 +- shippable.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index f0387b31..91185565 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.rulez.demokracia PDEngine - 0.0.1-feature_toolchain.c9495dd + 0.0.1-feature_toolchain.0146b03 war PDEngine diff --git a/shippable.yml b/shippable.yml index 622c100e..54dfc5da 100644 --- a/shippable.yml +++ b/shippable.yml @@ -9,7 +9,7 @@ build: cache_dir_list: - ~/.m2 ci: - - set |sed 's/[0-9]/X/g' + - set |sed 's/[0-9]/X/g' - /usr/local/toolchain/tools/Script on_success: - /usr/local/toolchain/tools/publish