TargetResource implements ITargetResource { @Override public Response createOrUpdateTarget( String rawProperties, String targetId ) { if( targetId == null ) this.logger.fine( "Request: create a new target." ); else this.logger.fine( "Request: update target " + targetId + "." ); Response response; String id = targetId; try { if( targetId == null ) id = this.manager.targetsMngr().createTarget( rawProperties ); else this.manager.targetsMngr().updateTarget( targetId, rawProperties ); response = Response.ok().entity( id ).build(); } catch( IOException | UnauthorizedActionException e ) { Status status = this.exceptionclassToErrorCode.get( e.getClass()); response = handleError( status, new RestError( ErrorCode.REST_SAVE_ERROR, e, ErrorDetails.name( targetId )), lang( this.manager )).build(); } return response; } TargetResource( Manager manager ); @Override List<TargetWrapperDescriptor> listTargets( String name, String qualifier ); @Override Response createOrUpdateTarget( String rawProperties, String targetId ); @Override Response loadTargetArchive( InputStream uploadedInputStream, FormDataContentDisposition fileDetail ); @Override Response deleteTarget( String targetId ); @Override Response getTargetProperties( String targetId ); @Override Response findTargetById( String targetId ); @Override Response associateTarget(
			String name,
			String qualifier,
			String instancePathOrComponentName,
			String targetId,
			boolean bind ); @Override Response updateHint( String name, String qualifier, String targetId, boolean bind ); @Override List<TargetUsageItem> findUsageStatistics( String targetId );  }
@Test public void testCreateOrupdateTarget_updateInexistingTarget() { Response resp = this.resource.createOrUpdateTarget( "prop: ok\nhandler: my handler", "4" ); Assert.assertEquals( Status.FORBIDDEN.getStatusCode(), resp.getStatus()); }