// -------------------------------------------------------------------------
  @SuppressWarnings({"rawtypes", "unchecked"})
  @Test
  public void testSearchBonds() {
    BondSecurity target =
        new GovernmentBondSecurity(
            "US TREASURY N/B",
            "Government",
            "US",
            "Treasury",
            Currency.USD,
            YieldConventionFactory.INSTANCE.getYieldConvention("US Treasury equivalent"),
            new Expiry(zdt(2011, 2, 1, 12, 0, 0, 0, ZoneOffset.UTC)),
            "",
            200,
            SimpleFrequencyFactory.INSTANCE.getFrequency(SimpleFrequency.SEMI_ANNUAL_NAME),
            DayCountFactory.INSTANCE.getDayCount("Actual/Actual"),
            zdt(2011, 2, 1, 12, 0, 0, 0, ZoneOffset.UTC),
            zdt(2011, 2, 1, 12, 0, 0, 0, ZoneOffset.UTC),
            zdt(2011, 2, 1, 12, 0, 0, 0, ZoneOffset.UTC),
            100d,
            100000000,
            5000,
            1000,
            100,
            100);
    target.setExternalIdBundle(ExternalIdBundle.of(ExternalId.of("A", "B")));
    Collection targetColl = ImmutableList.<Security>of(target);

    when(_underlying.getBondsWithIssuerName(eq("US TREASURY N/B"))).thenReturn(targetColl);

    Response test = _resource.searchBonds("US TREASURY N/B");
    assertEquals(Status.OK.getStatusCode(), test.getStatus());
    assertEquals(FudgeListWrapper.of(targetColl), test.getEntity());
  }
 // -------------------------------------------------------------------------
 @GET
 @Path("exchanges")
 public Response search(
     @QueryParam("versionAsOf") String versionAsOf,
     @QueryParam("correctedTo") String correctedTo,
     @QueryParam("id") List<String> externalIdStrs) {
   final VersionCorrection vc = VersionCorrection.parse(versionAsOf, correctedTo);
   final ExternalIdBundle bundle = ExternalIdBundle.parse(externalIdStrs);
   Collection<? extends Exchange> result = getExchangeSource().getExchanges(bundle, vc);
   return responseOkFudge(FudgeListWrapper.of(result));
 }
Example #3
0
  @SuppressWarnings({"rawtypes", "unchecked"})
  @Test
  public void testSearch() {
    final SimpleExchange target = new SimpleExchange();
    target.setName("Test");
    Collection targetColl = ImmutableList.of(target);

    when(_underlying.getConfigs(eq(SimpleExchange.class), eq(NAME), eq(VC))).thenReturn(targetColl);

    Response test =
        _resource.search(
            SimpleExchange.class.getName(),
            VC.getVersionAsOfString(),
            VC.getCorrectedToString(),
            NAME);
    assertEquals(Status.OK.getStatusCode(), test.getStatus());
    assertEquals(FudgeListWrapper.of(targetColl), test.getEntity());
  }