how to create imageset and add assets through java API in AEM 6.4



I have created a program with the following code:

ResourceResolver resourceResolver = resolverFactory.getResourceResolver(Collections.singletonMap("user.jcr.session", (Object) adminSession)); 

Resource damResource = resourceResolver.resolve("/content/dam/images");

ImageSet imageset = S7SetHelper.createS7ImageSet(damResource, "ImageSet", null);

Through this code, i am able to create an imageset.

Now, I want to add assets to this imageset. So, I wrote this code:

Asset asset = resourceResolver.getResource("/content/dam/images/Cycling.jpeg").adaptTo(Asset.class);


But this code is not working. Can anyone help with how to add assets to the imageset created.