Esempio n. 1
0
 // -------------------------------------------------------------------------
 public void test_getStartDate() {
   SwapLeg leg1 = MockSwapLeg.of(FIXED, PAY, date(2015, 6, 29), date(2017, 6, 30), Currency.USD);
   SwapLeg leg2 =
       MockSwapLeg.of(FIXED, RECEIVE, date(2015, 6, 30), date(2017, 6, 29), Currency.USD);
   assertEquals(Swap.of(leg1).getStartDate(), date(2015, 6, 29));
   assertEquals(Swap.of(leg2).getStartDate(), date(2015, 6, 30));
   assertEquals(Swap.of(leg1, leg2).getStartDate(), date(2015, 6, 29));
   assertEquals(Swap.of(leg2, leg1).getStartDate(), date(2015, 6, 29));
 }
Esempio n. 2
0
 public void test_getLeg_PayReceive() {
   assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).getLeg(PAY), Optional.of(MOCK_GBP1));
   assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).getLeg(RECEIVE), Optional.of(MOCK_USD1));
   assertEquals(Swap.of(MOCK_GBP1).getLeg(PAY), Optional.of(MOCK_GBP1));
   assertEquals(Swap.of(MOCK_USD1).getLeg(PAY), Optional.empty());
   assertEquals(Swap.of(MOCK_GBP1).getLeg(RECEIVE), Optional.empty());
   assertEquals(Swap.of(MOCK_USD1).getLeg(RECEIVE), Optional.of(MOCK_USD1));
 }
Esempio n. 3
0
 public void test_getReceiveLeg() {
   assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).getReceiveLeg(), Optional.of(MOCK_USD1));
   assertEquals(Swap.of(MOCK_GBP1).getReceiveLeg(), Optional.empty());
   assertEquals(Swap.of(MOCK_USD1).getReceiveLeg(), Optional.of(MOCK_USD1));
 }
Esempio n. 4
0
 // -------------------------------------------------------------------------
 public void test_getLegs_SwapLegType() {
   assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).getLegs(FIXED), ImmutableList.of(MOCK_GBP1));
   assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).getLegs(IBOR), ImmutableList.of(MOCK_USD1));
   assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).getLegs(OVERNIGHT), ImmutableList.of());
   assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).getLegs(OTHER), ImmutableList.of());
 }
Esempio n. 5
0
 public void test_of_list() {
   Swap test = Swap.of(ImmutableList.of(MOCK_GBP1, MOCK_USD1));
   assertEquals(test.getLegs(), ImmutableList.of(MOCK_GBP1, MOCK_USD1));
   assertEquals(ImmutableList.copyOf(test.getLegs()), ImmutableList.of(MOCK_GBP1, MOCK_USD1));
   assertThrowsIllegalArg(() -> Swap.of((List<SwapLeg>) null));
 }
Esempio n. 6
0
 public void test_serialization() {
   Swap test = Swap.of(MOCK_GBP1, MOCK_USD1);
   assertSerialization(test);
 }
Esempio n. 7
0
 // -------------------------------------------------------------------------
 public void coverage() {
   Swap test = Swap.of(MOCK_GBP1, MOCK_USD1);
   coverImmutableBean(test);
   Swap test2 = Swap.of(MOCK_GBP1);
   coverBeanEquals(test, test2);
 }
Esempio n. 8
0
 // -------------------------------------------------------------------------
 public void test_allIndices() {
   Swap test = Swap.of(MOCK_GBP1, MOCK_USD1);
   assertEquals(test.allIndices(), ImmutableSet.of());
 }
Esempio n. 9
0
 // -------------------------------------------------------------------------
 public void test_isCrossCurrency() {
   assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).isCrossCurrency(), true);
   assertEquals(Swap.of(MOCK_GBP1, MOCK_GBP2, MOCK_USD1).isCrossCurrency(), true);
   assertEquals(Swap.of(MOCK_GBP1, MOCK_GBP2).isCrossCurrency(), false);
   assertEquals(Swap.of(MOCK_GBP1).isCrossCurrency(), false);
 }