@Test public void should_link_context_to_identity() throws Exception { byte[] bytes = new byte[] {1, 2}; IdentityInsertModel identityInsertModel = new IdentityInsertModel(); identityInsertModel.setContextId("contextId"); identityInsertModel.setCertificate(bytes); IdentityModel identityModel = new IdentityModel(); given(identityService.linkContextToIdentity(identityInsertModel)).willReturn(Optional.of(identityModel)); IdentityModel result = identityResource.linkContextToIdentity(identityInsertModel, uriInfo); then(identityService).should().linkContextToIdentity(identityInsertModel); assertThat(result).isEqualTo(identityModel); }
@PUT @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public IdentityModel linkContextToIdentity(IdentityInsertModel identityInsertModel, @Context UriInfo uri) throws InvalidParseOperationException, CertificateException { ParametersChecker.checkParameter("ContextId cannot be null", identityInsertModel.getContextId()); ParametersChecker.checkParameter("Certificate cannot be null", (Object) identityInsertModel.getCertificate()); return identityService.linkContextToIdentity(identityInsertModel).orElseThrow(NotFoundException::new); }
AdminIdentityResource { @PUT @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public IdentityModel linkContextToIdentity(IdentityInsertModel identityInsertModel, @Context UriInfo uri) throws InvalidParseOperationException, CertificateException { ParametersChecker.checkParameter("ContextId cannot be null", identityInsertModel.getContextId()); ParametersChecker.checkParameter("Certificate cannot be null", (Object) identityInsertModel.getCertificate()); return identityService.linkContextToIdentity(identityInsertModel).orElseThrow(NotFoundException::new); } }
AdminIdentityResource { @PUT @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public IdentityModel linkContextToIdentity(IdentityInsertModel identityInsertModel, @Context UriInfo uri) throws InvalidParseOperationException, CertificateException { ParametersChecker.checkParameter("ContextId cannot be null", identityInsertModel.getContextId()); ParametersChecker.checkParameter("Certificate cannot be null", (Object) identityInsertModel.getCertificate()); return identityService.linkContextToIdentity(identityInsertModel).orElseThrow(NotFoundException::new); } AdminIdentityResource(IdentityService identityService); }
AdminIdentityResource { @PUT @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public IdentityModel linkContextToIdentity(IdentityInsertModel identityInsertModel, @Context UriInfo uri) throws InvalidParseOperationException, CertificateException { ParametersChecker.checkParameter("ContextId cannot be null", identityInsertModel.getContextId()); ParametersChecker.checkParameter("Certificate cannot be null", (Object) identityInsertModel.getCertificate()); return identityService.linkContextToIdentity(identityInsertModel).orElseThrow(NotFoundException::new); } AdminIdentityResource(IdentityService identityService); @POST @Consumes(MediaType.APPLICATION_JSON) Response createIdentity(IdentityInsertModel identityInsertModel, @Context UriInfo uri); @PUT @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) IdentityModel linkContextToIdentity(IdentityInsertModel identityInsertModel, @Context UriInfo uri); }
AdminIdentityResource { @PUT @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public IdentityModel linkContextToIdentity(IdentityInsertModel identityInsertModel, @Context UriInfo uri) throws InvalidParseOperationException, CertificateException { ParametersChecker.checkParameter("ContextId cannot be null", identityInsertModel.getContextId()); ParametersChecker.checkParameter("Certificate cannot be null", (Object) identityInsertModel.getCertificate()); return identityService.linkContextToIdentity(identityInsertModel).orElseThrow(NotFoundException::new); } AdminIdentityResource(IdentityService identityService); @POST @Consumes(MediaType.APPLICATION_JSON) Response createIdentity(IdentityInsertModel identityInsertModel, @Context UriInfo uri); @PUT @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) IdentityModel linkContextToIdentity(IdentityInsertModel identityInsertModel, @Context UriInfo uri);  }