DataFinancialSecuritySourceResource extends DataSecuritySourceResource { @GET @Path("securities/bonds") public Response searchBonds(@QueryParam("issuerName") String issuerName) { FinancialSecuritySource source = (FinancialSecuritySource) getSecuritySource(); Collection<? extends Security> result = source.getBondsWithIssuerName(issuerName); return responseOkObject(FudgeListWrapper.of(result)); } DataFinancialSecuritySourceResource(final SecuritySource securitySource); FinancialSecuritySource getSecuritySource(); @GET @Path("securities/bonds") Response searchBonds(@QueryParam("issuerName") String issuerName); static URI uriSearchBonds(URI baseUri, String issuerName);  }
@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), DayCounts.ACT_ACT_ISDA, 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()); }