WineryRepositoryClient implements IWineryRepositoryClient { @Override public void createArtifactTemplate(QName qname, QName artifactType) throws QNameAlreadyExistsException { WebTarget artifactTemplates = this.primaryWebTarget.path("artifacttemplates"); Map<String, String> root = new HashMap<>(); root.put("namespace", qname.getNamespaceURI()); root.put("localname", qname.getLocalPart()); root.put("type", artifactType.toString()); Response response = artifactTemplates.request(MediaType.TEXT_PLAIN) .post(Entity.json(root)); if (!response.getStatusInfo().getFamily().equals(Response.Status.Family.SUCCESSFUL)) { LOGGER.debug("Error {} when creating id {} from URI {}", response.getStatus(), qname.toString(), this.primaryWebTarget.getUri().toString()); String entity = response.readEntity(String.class); if (entity != null) { LOGGER.debug("Entity: {}", entity); } throw new QNameAlreadyExistsException(); } } WineryRepositoryClient();  WineryRepositoryClient(boolean useProxy); @Override void addRepository(String uri); @Override String getPrimaryRepository(); @Override void setPrimaryRepository(String uri); @Override SortedSet<String> getNamespaces(); @Override String getName(GenericId id); @Override List<QName> getQNameListOfAllTypes(Class<T> className); @Override Collection<QNameWithName> getListOfAllInstances(Class<? extends DefinitionsChildId> clazz); @Override Collection<T> getAllTypes(Class<T> c); @Override @SuppressWarnings("unchecked") T getType(QName qname, Class<T> type); @Override Definitions getDefinitions(DefinitionsChildId id); @Override Collection<TDefinitions> getAllTypesWithAssociatedElements(Class<T> c); @Override TTopologyTemplate getTopologyTemplate(QName serviceTemplate); @Override TTopologyTemplate getTopologyTemplate(QName serviceTemplate, String parentPath, String elementPath); @Override void setTopologyTemplate(QName serviceTemplate, TTopologyTemplate topologyTemplate); @Override QName getArtifactTypeQNameForExtension(String extension); @Override void createArtifactTemplate(QName qname, QName artifactType); @Override void createComponent(QName qname, Class<? extends DefinitionsChildId> idClass); @Override void forceDelete(GenericId id); @Override void rename(DefinitionsChildId oldId, DefinitionsChildId newId); @Override void duplicate(DefinitionsChildId from, DefinitionsChildId newId); @Override void forceDelete(Class<? extends DefinitionsChildId> definitionsChildIdClazz, Namespace namespace); @Override boolean primaryRepositoryAvailable(); static final JAXBContext context; }
@Test public void createArtifactTemplate() throws Exception { this.setRevisionTo("origin/plain"); QName artifactTypeQName = TestWineryRepositoryClient.client.getArtifactTypeQNameForExtension("war"); assertNotNull(artifactTypeQName, "Artifact Type for .war does not exist"); QName artifactTemplateQName = new QName(TestWineryRepositoryClient.NAMESPACE_FOR_NEW_ARTIFACTS, "artifactTemplate"); ArtifactTemplateId atId = new ArtifactTemplateId(artifactTemplateQName); TestWineryRepositoryClient.client.forceDelete(atId); TestWineryRepositoryClient.client.createArtifactTemplate(artifactTemplateQName, artifactTypeQName); }