@Test public void getReferenceBook() throws IOException { String container = "someContainer"; Main.getWorkMgr().initNetwork(container, null); Main.getWorkMgr() .putReferenceLibrary( new ReferenceLibrary(ImmutableList.of(ReferenceBook.builder("book1").build())), container); try (Response response = getReferenceBookTarget(container, "book1").get()) { assertThat(response.getStatus(), equalTo(OK.getStatusCode())); assertThat( response.readEntity(ReferenceBook.class), equalTo(ReferenceBook.builder("book1").build())); } try (Response response2 = getReferenceBookTarget(container, "book2").get()) { assertThat(response2.getStatus(), equalTo(NOT_FOUND.getStatusCode())); } }
@GET public ReferenceBookBean getReferenceBook() { _logger.infof("WMS2: getReferenceBook: '%s' '%s'\n", _network, _bookName); try { return new ReferenceBookBean( Main.getWorkMgr() .getReferenceLibrary(_network) .getReferenceBook(_bookName) .orElseThrow( () -> new NotFoundException( String.format( "Reference book '%s' not found in container '%s'", _bookName, _network)))); } catch (IOException e) { throw new InternalServerErrorException("Reference library data is corrupted"); } }
ReferenceBookResource { @GET public ReferenceBookBean getReferenceBook() { _logger.infof("WMS2: getReferenceBook: '%s' '%s'\n", _network, _bookName); try { return new ReferenceBookBean( Main.getWorkMgr() .getReferenceLibrary(_network) .getReferenceBook(_bookName) .orElseThrow( () -> new NotFoundException( String.format( "Reference book '%s' not found in container '%s'", _bookName, _network)))); } catch (IOException e) { throw new InternalServerErrorException("Reference library data is corrupted"); } } }
ReferenceBookResource { @GET public ReferenceBookBean getReferenceBook() { _logger.infof("WMS2: getReferenceBook: '%s' '%s'\n", _network, _bookName); try { return new ReferenceBookBean( Main.getWorkMgr() .getReferenceLibrary(_network) .getReferenceBook(_bookName) .orElseThrow( () -> new NotFoundException( String.format( "Reference book '%s' not found in container '%s'", _bookName, _network)))); } catch (IOException e) { throw new InternalServerErrorException("Reference library data is corrupted"); } } ReferenceBookResource(String network, String book); }
ReferenceBookResource { @GET public ReferenceBookBean getReferenceBook() { _logger.infof("WMS2: getReferenceBook: '%s' '%s'\n", _network, _bookName); try { return new ReferenceBookBean( Main.getWorkMgr() .getReferenceLibrary(_network) .getReferenceBook(_bookName) .orElseThrow( () -> new NotFoundException( String.format( "Reference book '%s' not found in container '%s'", _bookName, _network)))); } catch (IOException e) { throw new InternalServerErrorException("Reference library data is corrupted"); } } ReferenceBookResource(String network, String book); @DELETE Response delReferenceBook(); @GET ReferenceBookBean getReferenceBook(); @PUT Response putReferenceBook(ReferenceBookBean referenceBookBean); }
ReferenceBookResource { @GET public ReferenceBookBean getReferenceBook() { _logger.infof("WMS2: getReferenceBook: '%s' '%s'\n", _network, _bookName); try { return new ReferenceBookBean( Main.getWorkMgr() .getReferenceLibrary(_network) .getReferenceBook(_bookName) .orElseThrow( () -> new NotFoundException( String.format( "Reference book '%s' not found in container '%s'", _bookName, _network)))); } catch (IOException e) { throw new InternalServerErrorException("Reference library data is corrupted"); } } ReferenceBookResource(String network, String book); @DELETE Response delReferenceBook(); @GET ReferenceBookBean getReferenceBook(); @PUT Response putReferenceBook(ReferenceBookBean referenceBookBean);  }