Skip to content

Commit

Permalink
make lists read/write in the example instances
Browse files Browse the repository at this point in the history
  • Loading branch information
pahjbo committed Jul 31, 2024
1 parent 863e266 commit 1c4a1e9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
17 changes: 15 additions & 2 deletions src/test/java/org/ivoa/dm/proposal/prop/BaseExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -41,7 +42,7 @@ public abstract class BaseExample implements ExampleGenerator {
new Person("Nevil Maskelyne ", "[email protected]", institutes[1], new StringIdentifier("https://notreallyorcid.org/0000-0001-0002-007")),

};
protected List<Investigator> investigators = Arrays.asList(
protected List<Investigator> investigators = makeList(
new Investigator ( people[0], InvestigatorKind.PI, false ),
new Investigator ( people[1], InvestigatorKind.COI, true ));

Expand All @@ -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)
));
Expand Down Expand Up @@ -101,6 +102,18 @@ protected Telescope createTelescope(String name, double x, double y, double z) {
}));

}


/**
* make a read-write list.
*
* @param <T> list type
* @param a objects
* @return a list
*/
protected <T> List<T> makeList(T... a) {
return new ArrayList<T>(Arrays.asList(a));
}
/**
* {@inheritDoc}
* overrides @see org.ivoa.dm.proposal.prop.ExampleGenerator#getICRF()
Expand Down
22 changes: 11 additions & 11 deletions src/test/java/org/ivoa/dm/proposal/prop/EmerlinExample.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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?
Expand All @@ -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<Observation> obs = Arrays.asList(
pr.targets = makeList(target);
pr.fields = makeList(field);
pr.technicalGoals = makeList(tgoal);
List<Observation> 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)
);
}
Expand All @@ -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 -> {
Expand All @@ -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];
Expand Down

0 comments on commit 1c4a1e9

Please sign in to comment.