@Test public void putReferenceBookSuccess() throws IOException { String network = "someContainer"; String bookName = "book1"; Main.getWorkMgr().initNetwork(network, null); ReferenceBookBean book = new ReferenceBookBean(ReferenceBook.builder(bookName).build()); try (Response response = getReferenceBookTarget(network, bookName) .put(Entity.entity(book, MediaType.APPLICATION_JSON))) { assertThat(response.getStatus(), equalTo(OK.getStatusCode())); } ReferenceLibrary library = Main.getWorkMgr().getReferenceLibrary(network); assertThat(library.getReferenceBook(bookName).isPresent(), equalTo(true)); AddressGroup ag = new AddressGroup(null, "ag"); book.addressGroups = ImmutableSet.of(new AddressGroupBean(ag)); try (Response response2 = getReferenceBookTarget(network, bookName) .put(Entity.entity(book, MediaType.APPLICATION_JSON))) { assertThat(response2.getStatus(), equalTo(OK.getStatusCode())); } ReferenceBook book2 = Main.getWorkMgr().getReferenceLibrary(network).getReferenceBook(bookName).get(); assertThat(book2.getAddressGroups(), equalTo(ImmutableSet.of(ag))); }
@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);  }