@Test public void should_return_not_found_when_certificate_is_missing() throws Exception { byte[] bytes = new byte[] {1, 2}; IdentityInsertModel identityModel = new IdentityInsertModel(); identityModel.setContextId("contextId"); identityModel.setCertificate(bytes); given(identityService.linkContextToIdentity(identityModel)).willReturn(Optional.empty()); assertThatThrownBy(() -> identityResource.linkContextToIdentity(identityModel, uriInfo)) .isInstanceOf(NotFoundException.class); }
@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);  }