From 1c4a1e9f59ab175c2bcf973fa573ac5efc350682 Mon Sep 17 00:00:00 2001 From: Paul Harrison Date: Wed, 31 Jul 2024 17:59:29 +0100 Subject: [PATCH] make lists read/write in the example instances --- .../ivoa/dm/proposal/prop/BaseExample.java | 17 ++++++++++++-- .../ivoa/dm/proposal/prop/EmerlinExample.java | 22 +++++++++---------- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/test/java/org/ivoa/dm/proposal/prop/BaseExample.java b/src/test/java/org/ivoa/dm/proposal/prop/BaseExample.java index dba8d33..505ebf2 100644 --- a/src/test/java/org/ivoa/dm/proposal/prop/BaseExample.java +++ b/src/test/java/org/ivoa/dm/proposal/prop/BaseExample.java @@ -13,6 +13,7 @@ import org.ivoa.dm.ivoa.StringIdentifier; import org.ivoa.vodml.stdtypes.Unit; +import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.GregorianCalendar; @@ -41,7 +42,7 @@ public abstract class BaseExample implements ExampleGenerator { new Person("Nevil Maskelyne ", "reviewer@unreal.not.email", institutes[1], new StringIdentifier("https://notreallyorcid.org/0000-0001-0002-007")), }; - protected List investigators = Arrays.asList( + protected List investigators = makeList( new Investigator ( people[0], InvestigatorKind.PI, false ), new Investigator ( people[1], InvestigatorKind.COI, true )); @@ -50,7 +51,7 @@ public abstract class BaseExample implements ExampleGenerator { new Reviewer(people[4])// reviewer not on TAC }; - protected TAC tac = new TAC( Arrays.asList( + protected TAC tac = new TAC( makeList( new CommitteeMember( reviewers[0], TacRole.CHAIR ), new CommitteeMember ( reviewers[1], TacRole.SCIENCEREVIEWER) )); @@ -101,6 +102,18 @@ protected Telescope createTelescope(String name, double x, double y, double z) { })); } + + + /** + * make a read-write list. + * + * @param list type + * @param a objects + * @return a list + */ + protected List makeList(T... a) { + return new ArrayList(Arrays.asList(a)); + } /** * {@inheritDoc} * overrides @see org.ivoa.dm.proposal.prop.ExampleGenerator#getICRF() diff --git a/src/test/java/org/ivoa/dm/proposal/prop/EmerlinExample.java b/src/test/java/org/ivoa/dm/proposal/prop/EmerlinExample.java index 41008ed..d969047 100644 --- a/src/test/java/org/ivoa/dm/proposal/prop/EmerlinExample.java +++ b/src/test/java/org/ivoa/dm/proposal/prop/EmerlinExample.java @@ -122,7 +122,7 @@ public EmerlinExample () { p.desiredLargestScale = new RealQuantity(0.1, degrees); p.representativeSpectralPoint = new RealQuantity(1.5, ghz); }); - g.spectrum = Arrays.asList( + g.spectrum = makeList( createScienceSpectralWindow(ssw -> { ssw.spectralWindowSetup = createSpectralWindowSetup(sw -> { // continuum sw.start = new RealQuantity(1.2, ghz); @@ -135,7 +135,7 @@ public EmerlinExample () { }), createScienceSpectralWindow(ssw -> { // narrow window for line - ssw.expectedSpectralLine = Arrays.asList(createExpectedSpectralLine(sl -> { + ssw.expectedSpectralLine = makeList(createExpectedSpectralLine(sl -> { sl.restFrequency = new RealQuantity(1.4204058, ghz); sl.description = "HI"; sl.splatalogId = new StringIdentifier("00101");//IMPL is stringIdentifier really useful? @@ -154,15 +154,15 @@ public EmerlinExample () { }); // set up the specific proposal proposal = createObservingProposal(proposalCommonSetup().andThen(pr -> { - pr.targets = Arrays.asList(target); - pr.fields = Arrays.asList(field); - pr.technicalGoals = Arrays.asList(tgoal); - List obs = Arrays.asList( + pr.targets = makeList(target); + pr.fields = makeList(field); + pr.technicalGoals = makeList(tgoal); + List obs =makeList( //IMPL note the wrapping in a new ArrayList as otherwise the list is readonly, and we want to add observations in the tests createTargetObservation(t -> { - t.target = Arrays.asList(target); + t.target = makeList(target); t.field = field; t.technicalGoal = tgoal; - t.constraints = Arrays.asList( + t.constraints = makeList( new TimingWindow(new Date(2023, 1, 1), new Date(2023, 1, 10), "t constraint", false) ); } @@ -175,7 +175,7 @@ public EmerlinExample () { // "submit" proposal final SubmittedProposal submittedProposal = new SubmittedProposal( proposal, new GregorianCalendar(2022, 3, 14).getTime(), false, new GregorianCalendar(2022, 4, 30).getTime(), null ); cycle.setSubmittedProposals( - Arrays.asList(submittedProposal)); + makeList(submittedProposal)); // "review" proposal ProposalReview review = ProposalReview.createProposalReview(pr -> { @@ -191,11 +191,11 @@ public EmerlinExample () { // "allocate" proposal - cycle.setAllocatedProposals(Arrays.asList( + cycle.setAllocatedProposals(makeList( AllocatedProposal.createAllocatedProposal(ap -> { ap.submitted = submittedProposal; - ap.allocation = Arrays.asList( + ap.allocation = makeList( AllocatedBlock.createAllocatedBlock( a -> { a.grade = grades[0];