### Question:
FrameworkResource { @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) public Framework saveFramework(@FormDataParam("file") byte[] frameworkJar, @FormDataParam("isPublic") @DefaultValue("false") boolean isPublic) { return frameworkService.addFramework(frameworkJar, isPublic); } @Inject  FrameworkResource(FrameworkService frameworkService,
            ComponentService componentService, ResourceService resourceService,
            SerializationService serializationService); @GET @Produces(MediaType.APPLICATION_JSON) List<Framework> listFrameworks(); @POST @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces(MediaType.APPLICATION_JSON) Framework saveFramework(@FormDataParam("file") byte[] frameworkJar, 
            @FormDataParam("isPublic") @DefaultValue("false") boolean isPublic); @GET @Path("/{frameworkId}") @Produces(MediaType.APPLICATION_JSON) Framework getFramework(@PathParam("frameworkId") String frameworkId); @DELETE @Path("/{frameworkId}") Response deleteFramework(@PathParam("frameworkId") String frameworkId); @GET @Path("/{frameworkId}/jar") @Produces("application/java-archive") Response getFrameworkJar(@PathParam("frameworkId") String frameworkId); @GET @Path("/{frameworkId}/components") @Produces(MediaType.APPLICATION_JSON) List<Component> getFrameworkComponents(@PathParam("frameworkId") String frameworkId); @GET @Path("/{frameworkId}/resources") @Produces(MediaType.APPLICATION_JSON) List<Resource> getFrameworkResources(@PathParam("frameworkId") String frameworkId); @GET @Path("/{frameworkId}/serializations") @Produces(MediaType.APPLICATION_JSON) List<Serialization> getFrameworkSerializations(@PathParam("frameworkId") String frameworkId);  }### Answer:
@Test public void saveFramework() { final byte[] mockedFrameworkJar = "FRAMEWORK FILE CONTENTS".getBytes(); final Framework mockedFramework = new Framework(); mockedFramework.setId("test-framework"); mockedFramework.setName("test-framework"); mockedFramework.setLabel("Test Framework"); mockedFramework.setPublic(true); when(frameworkServiceMock.addFramework(any(byte[].class), anyBoolean())).then(new Answer<Framework>() { @Override public Framework answer(InvocationOnMock invocation) { byte[] argFrameworkJar = (byte[]) invocation.getArguments()[0]; boolean argIsPublic = (Boolean) invocation.getArguments()[1]; assertTrue("Service framework jar should equal the requested framework jar", Arrays.equals(mockedFrameworkJar, argFrameworkJar)); assertEquals("Service framework visibility should equal the requested framework visibility", mockedFramework.isPublic(), argIsPublic); return mockedFramework; } }); FormDataMultiPart formData = new FormDataMultiPart(); formData.field("isPublic", Boolean.toString(mockedFramework.isPublic())); formData.field("file", mockedFrameworkJar, MediaType.APPLICATION_OCTET_STREAM_TYPE); Framework responseFramework = resource().path("/api/frameworks") .accept(MediaType.APPLICATION_JSON).type(MediaType.MULTIPART_FORM_DATA) .post(Framework.class, formData); assertEquals("Response framework should equal the mocked framework", mockedFramework, responseFramework); verify(frameworkServiceMock).addFramework(any(byte[].class), anyBoolean()); }