use of org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact in project carbon-apimgt by wso2.
the class APIUtil method getDocumentation.
/**
* Create the Documentation from artifact
*
* @param artifact Documentation artifact
* @return Documentation
* @throws APIManagementException if failed to create Documentation from artifact
*/
public static Documentation getDocumentation(GenericArtifact artifact) throws APIManagementException {
Documentation documentation;
try {
DocumentationType type;
String docType = artifact.getAttribute(APIConstants.DOC_TYPE);
if (docType.equalsIgnoreCase(DocumentationType.HOWTO.getType())) {
type = DocumentationType.HOWTO;
} else if (docType.equalsIgnoreCase(DocumentationType.PUBLIC_FORUM.getType())) {
type = DocumentationType.PUBLIC_FORUM;
} else if (docType.equalsIgnoreCase(DocumentationType.SUPPORT_FORUM.getType())) {
type = DocumentationType.SUPPORT_FORUM;
} else if (docType.equalsIgnoreCase(DocumentationType.API_MESSAGE_FORMAT.getType())) {
type = DocumentationType.API_MESSAGE_FORMAT;
} else if (docType.equalsIgnoreCase(DocumentationType.SAMPLES.getType())) {
type = DocumentationType.SAMPLES;
} else {
type = DocumentationType.OTHER;
}
documentation = new Documentation(type, artifact.getAttribute(APIConstants.DOC_NAME));
documentation.setId(artifact.getId());
documentation.setSummary(artifact.getAttribute(APIConstants.DOC_SUMMARY));
String visibilityAttr = artifact.getAttribute(APIConstants.DOC_VISIBILITY);
Documentation.DocumentVisibility documentVisibility = Documentation.DocumentVisibility.API_LEVEL;
if (visibilityAttr != null) {
if (visibilityAttr.equals(Documentation.DocumentVisibility.API_LEVEL.name())) {
documentVisibility = Documentation.DocumentVisibility.API_LEVEL;
} else if (visibilityAttr.equals(Documentation.DocumentVisibility.PRIVATE.name())) {
documentVisibility = Documentation.DocumentVisibility.PRIVATE;
} else if (visibilityAttr.equals(Documentation.DocumentVisibility.OWNER_ONLY.name())) {
documentVisibility = Documentation.DocumentVisibility.OWNER_ONLY;
}
}
documentation.setVisibility(documentVisibility);
Documentation.DocumentSourceType docSourceType = Documentation.DocumentSourceType.INLINE;
String artifactAttribute = artifact.getAttribute(APIConstants.DOC_SOURCE_TYPE);
if (Documentation.DocumentSourceType.URL.name().equals(artifactAttribute)) {
docSourceType = Documentation.DocumentSourceType.URL;
documentation.setSourceUrl(artifact.getAttribute(APIConstants.DOC_SOURCE_URL));
} else if (Documentation.DocumentSourceType.FILE.name().equals(artifactAttribute)) {
docSourceType = Documentation.DocumentSourceType.FILE;
documentation.setFilePath(prependWebContextRoot(artifact.getAttribute(APIConstants.DOC_FILE_PATH)));
} else if (Documentation.DocumentSourceType.MARKDOWN.name().equals(artifactAttribute)) {
docSourceType = Documentation.DocumentSourceType.MARKDOWN;
}
documentation.setSourceType(docSourceType);
if (documentation.getType() == DocumentationType.OTHER) {
documentation.setOtherTypeName(artifact.getAttribute(APIConstants.DOC_OTHER_TYPE_NAME));
}
} catch (GovernanceException e) {
throw new APIManagementException("Failed to get documentation from artifact", e);
}
return documentation;
}
use of org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact in project carbon-apimgt by wso2.
the class APIUtil method createAPIArtifactContent.
/**
* Create Governance artifact from given attributes
*
* @param artifact initial governance artifact
* @param api API object with the attributes value
* @return GenericArtifact
* @throws org.wso2.carbon.apimgt.api.APIManagementException if failed to create API
*/
public static GenericArtifact createAPIArtifactContent(GenericArtifact artifact, API api) throws APIManagementException {
try {
String apiStatus = api.getStatus();
artifact.setAttribute(APIConstants.API_OVERVIEW_NAME, api.getId().getApiName());
artifact.setAttribute(APIConstants.API_OVERVIEW_VERSION, api.getId().getVersion());
artifact.setAttribute(APIConstants.API_OVERVIEW_VERSION_TIMESTAMP, api.getVersionTimestamp());
artifact.setAttribute(APIConstants.API_OVERVIEW_CONTEXT, api.getContext());
artifact.setAttribute(APIConstants.API_OVERVIEW_PROVIDER, api.getId().getProviderName());
artifact.setAttribute(APIConstants.API_OVERVIEW_DESCRIPTION, api.getDescription());
artifact.setAttribute(APIConstants.API_OVERVIEW_WSDL, api.getWsdlUrl());
artifact.setAttribute(APIConstants.API_OVERVIEW_WADL, api.getWadlUrl());
artifact.setAttribute(APIConstants.API_OVERVIEW_THUMBNAIL_URL, api.getThumbnailUrl());
artifact.setAttribute(APIConstants.API_OVERVIEW_STATUS, apiStatus);
artifact.setAttribute(APIConstants.API_OVERVIEW_TEC_OWNER, api.getTechnicalOwner());
artifact.setAttribute(APIConstants.API_OVERVIEW_TEC_OWNER_EMAIL, api.getTechnicalOwnerEmail());
artifact.setAttribute(APIConstants.API_OVERVIEW_BUSS_OWNER, api.getBusinessOwner());
artifact.setAttribute(APIConstants.API_OVERVIEW_BUSS_OWNER_EMAIL, api.getBusinessOwnerEmail());
artifact.setAttribute(APIConstants.API_OVERVIEW_VISIBILITY, api.getVisibility());
artifact.setAttribute(APIConstants.API_OVERVIEW_VISIBLE_ROLES, api.getVisibleRoles());
artifact.setAttribute(APIConstants.API_OVERVIEW_VISIBLE_TENANTS, api.getVisibleTenants());
artifact.setAttribute(APIConstants.API_OVERVIEW_ENDPOINT_SECURED, Boolean.toString(api.isEndpointSecured()));
artifact.setAttribute(APIConstants.API_OVERVIEW_ENDPOINT_AUTH_DIGEST, Boolean.toString(api.isEndpointAuthDigest()));
artifact.setAttribute(APIConstants.API_OVERVIEW_ENDPOINT_USERNAME, api.getEndpointUTUsername());
artifact.setAttribute(APIConstants.API_OVERVIEW_ENDPOINT_PASSWORD, api.getEndpointUTPassword());
artifact.setAttribute(APIConstants.API_OVERVIEW_TRANSPORTS, api.getTransports());
artifact.setAttribute(APIConstants.API_OVERVIEW_INSEQUENCE, api.getInSequence());
artifact.setAttribute(APIConstants.API_OVERVIEW_OUTSEQUENCE, api.getOutSequence());
artifact.setAttribute(APIConstants.API_OVERVIEW_FAULTSEQUENCE, api.getFaultSequence());
artifact.setAttribute(APIConstants.API_OVERVIEW_RESPONSE_CACHING, api.getResponseCache());
artifact.setAttribute(APIConstants.API_OVERVIEW_CACHE_TIMEOUT, Integer.toString(api.getCacheTimeout()));
artifact.setAttribute(APIConstants.API_OVERVIEW_REDIRECT_URL, api.getRedirectURL());
artifact.setAttribute(APIConstants.API_OVERVIEW_EXTERNAL_PRODUCTION_ENDPOINT, api.getApiExternalProductionEndpoint());
artifact.setAttribute(APIConstants.API_OVERVIEW_EXTERNAL_SANDBOX_ENDPOINT, api.getApiExternalSandboxEndpoint());
artifact.setAttribute(APIConstants.API_OVERVIEW_OWNER, api.getApiOwner());
artifact.setAttribute(APIConstants.API_OVERVIEW_ADVERTISE_ONLY, Boolean.toString(api.isAdvertiseOnly()));
artifact.setAttribute(APIConstants.API_OVERVIEW_ENDPOINT_CONFIG, api.getEndpointConfig());
artifact.setAttribute(APIConstants.API_OVERVIEW_SUBSCRIPTION_AVAILABILITY, api.getSubscriptionAvailability());
artifact.setAttribute(APIConstants.API_OVERVIEW_SUBSCRIPTION_AVAILABLE_TENANTS, api.getSubscriptionAvailableTenants());
artifact.setAttribute(APIConstants.PROTOTYPE_OVERVIEW_IMPLEMENTATION, api.getImplementation());
artifact.setAttribute(APIConstants.API_PRODUCTION_THROTTLE_MAXTPS, api.getProductionMaxTps());
artifact.setAttribute(APIConstants.API_SANDBOX_THROTTLE_MAXTPS, api.getSandboxMaxTps());
artifact.setAttribute(APIConstants.API_OVERVIEW_AUTHORIZATION_HEADER, api.getAuthorizationHeader());
artifact.setAttribute(APIConstants.API_OVERVIEW_API_SECURITY, api.getApiSecurity());
artifact.setAttribute(APIConstants.API_OVERVIEW_ENABLE_JSON_SCHEMA, Boolean.toString(api.isEnabledSchemaValidation()));
artifact.setAttribute(APIConstants.API_OVERVIEW_ENABLE_STORE, Boolean.toString(api.isEnableStore()));
artifact.setAttribute(APIConstants.API_OVERVIEW_TESTKEY, api.getTestKey());
// Validate if the API has an unsupported context before setting it in the artifact
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantDomain();
if (APIConstants.SUPER_TENANT_DOMAIN.equals(tenantDomain)) {
String invalidContext = File.separator + APIConstants.VERSION_PLACEHOLDER;
if (invalidContext.equals(api.getContextTemplate())) {
throw new APIManagementException("API : " + api.getId() + " has an unsupported context : " + api.getContextTemplate());
}
} else {
String invalidContext = APIConstants.TENANT_PREFIX + tenantDomain + File.separator + APIConstants.VERSION_PLACEHOLDER;
if (invalidContext.equals(api.getContextTemplate())) {
throw new APIManagementException("API : " + api.getId() + " has an unsupported context : " + api.getContextTemplate());
}
}
// This is to support the pluggable version strategy.
artifact.setAttribute(APIConstants.API_OVERVIEW_CONTEXT_TEMPLATE, api.getContextTemplate());
artifact.setAttribute(APIConstants.API_OVERVIEW_VERSION_TYPE, "context");
artifact.setAttribute(APIConstants.API_OVERVIEW_TYPE, api.getType());
StringBuilder policyBuilder = new StringBuilder();
for (Tier tier : api.getAvailableTiers()) {
policyBuilder.append(tier.getName());
policyBuilder.append("||");
}
String policies = policyBuilder.toString();
if (!"".equals(policies)) {
policies = policies.substring(0, policies.length() - 2);
artifact.setAttribute(APIConstants.API_OVERVIEW_TIER, policies);
}
StringBuilder tiersBuilder = new StringBuilder();
for (Tier tier : api.getAvailableTiers()) {
tiersBuilder.append(tier.getName());
tiersBuilder.append("||");
}
String tiers = tiersBuilder.toString();
if (!"".equals(tiers)) {
tiers = tiers.substring(0, tiers.length() - 2);
artifact.setAttribute(APIConstants.API_OVERVIEW_TIER, tiers);
} else {
artifact.setAttribute(APIConstants.API_OVERVIEW_TIER, tiers);
}
if (APIConstants.PUBLISHED.equals(apiStatus)) {
artifact.setAttribute(APIConstants.API_OVERVIEW_IS_LATEST, "true");
}
String[] keys = artifact.getAttributeKeys();
for (String key : keys) {
if (key.contains("URITemplate")) {
artifact.removeAttribute(key);
}
}
Set<URITemplate> uriTemplateSet = api.getUriTemplates();
int i = 0;
for (URITemplate uriTemplate : uriTemplateSet) {
artifact.addAttribute(APIConstants.API_URI_PATTERN + i, uriTemplate.getUriTemplate());
artifact.addAttribute(APIConstants.API_URI_HTTP_METHOD + i, uriTemplate.getHTTPVerb());
artifact.addAttribute(APIConstants.API_URI_AUTH_TYPE + i, uriTemplate.getAuthType());
i++;
}
artifact.setAttribute(APIConstants.API_OVERVIEW_ENVIRONMENTS, writeEnvironmentsToArtifact(api));
artifact.setAttribute(APIConstants.API_OVERVIEW_CORS_CONFIGURATION, APIUtil.getCorsConfigurationJsonFromDto(api.getCorsConfiguration()));
artifact.setAttribute(APIConstants.API_OVERVIEW_WEBSUB_SUBSCRIPTION_CONFIGURATION, APIUtil.getWebsubSubscriptionConfigurationJsonFromDto(api.getWebsubSubscriptionConfiguration()));
artifact.setAttribute(APIConstants.API_OVERVIEW_WS_URI_MAPPING, APIUtil.getWsUriMappingJsonFromDto(api.getWsUriMapping()));
// attaching api categories to the API
List<APICategory> attachedApiCategories = api.getApiCategories();
artifact.removeAttribute(APIConstants.API_CATEGORIES_CATEGORY_NAME);
if (attachedApiCategories != null) {
for (APICategory category : attachedApiCategories) {
artifact.addAttribute(APIConstants.API_CATEGORIES_CATEGORY_NAME, category.getName());
}
}
// set monetization status (i.e - enabled or disabled)
artifact.setAttribute(APIConstants.Monetization.API_MONETIZATION_STATUS, Boolean.toString(api.getMonetizationStatus()));
// set additional monetization data
if (api.getMonetizationProperties() != null) {
artifact.setAttribute(APIConstants.Monetization.API_MONETIZATION_PROPERTIES, api.getMonetizationProperties().toJSONString());
}
if (api.getKeyManagers() != null) {
artifact.setAttribute(APIConstants.API_OVERVIEW_KEY_MANAGERS, new Gson().toJson(api.getKeyManagers()));
}
// check in github code to see this method was removed
String apiSecurity = artifact.getAttribute(APIConstants.API_OVERVIEW_API_SECURITY);
if (apiSecurity != null && !apiSecurity.contains(APIConstants.DEFAULT_API_SECURITY_OAUTH2) && !apiSecurity.contains(APIConstants.API_SECURITY_API_KEY)) {
artifact.setAttribute(APIConstants.API_OVERVIEW_TIER, "");
}
} catch (GovernanceException e) {
String msg = "Failed to create API for : " + api.getId().getApiName();
log.error(msg, e);
throw new APIManagementException(msg, e);
}
return artifact;
}
use of org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact in project carbon-apimgt by wso2.
the class DocumentIndexer method fetchDocumentContent.
/**
* Write document content to document artifact as its raw content
*
* @param registry
* @param documentResource
* @return
* @throws RegistryException
* @throws IOException
* @throws APIManagementException
*/
private String fetchDocumentContent(Registry registry, Resource documentResource) throws RegistryException, IOException, APIManagementException {
GenericArtifactManager docArtifactManager = APIUtil.getArtifactManager(registry, APIConstants.DOCUMENTATION_KEY);
GenericArtifact documentArtifact = docArtifactManager.getGenericArtifact(documentResource.getUUID());
String sourceType = documentArtifact.getAttribute(APIConstants.DOC_SOURCE_TYPE);
String contentString = null;
if (Documentation.DocumentSourceType.FILE.name().equals(sourceType)) {
String path = documentArtifact.getAttribute(APIConstants.DOC_FILE_PATH);
int indexOfApimgt = path.indexOf(APIConstants.APIMGT_REGISTRY_LOCATION);
String filepath = path.substring(indexOfApimgt);
Resource contentResource = registry.get(filepath);
int indexOfFiles = filepath.indexOf(APIConstants.DOCUMENT_FILE_DIR) + APIConstants.DOCUMENT_FILE_DIR.length() + 1;
String fileName = filepath.substring(indexOfFiles);
String extension = FilenameUtils.getExtension(fileName);
InputStream inputStream = null;
try {
inputStream = contentResource.getContentStream();
switch(extension) {
case APIConstants.PDF_EXTENSION:
PDFParser pdfParser = new PDFParser(new RandomAccessBufferedFileInputStream(inputStream));
pdfParser.parse();
COSDocument cosDocument = pdfParser.getDocument();
PDFTextStripper stripper = new PDFTextStripper();
contentString = stripper.getText(new PDDocument(cosDocument));
break;
case APIConstants.DOC_EXTENSION:
{
POIFSFileSystem pfs = new POIFSFileSystem(inputStream);
WordExtractor msWord2003Extractor = new WordExtractor(pfs);
contentString = msWord2003Extractor.getText();
break;
}
case APIConstants.DOCX_EXTENSION:
XWPFDocument doc = new XWPFDocument(inputStream);
XWPFWordExtractor msWord2007Extractor = new XWPFWordExtractor(doc);
contentString = msWord2007Extractor.getText();
break;
case APIConstants.XLS_EXTENSION:
{
POIFSFileSystem pfs = new POIFSFileSystem(inputStream);
ExcelExtractor extractor = new ExcelExtractor(pfs);
contentString = extractor.getText();
break;
}
case APIConstants.XLSX_EXTENSION:
XSSFWorkbook xssfSheets = new XSSFWorkbook(inputStream);
XSSFExcelExtractor xssfExcelExtractor = new XSSFExcelExtractor(xssfSheets);
contentString = xssfExcelExtractor.getText();
break;
case APIConstants.PPT_EXTENSION:
{
POIFSFileSystem fs = new POIFSFileSystem(inputStream);
PowerPointExtractor extractor = new PowerPointExtractor(fs);
contentString = extractor.getText();
break;
}
case APIConstants.PPTX_EXTENSION:
XMLSlideShow xmlSlideShow = new XMLSlideShow(inputStream);
XSLFPowerPointExtractor xslfPowerPointExtractor = new XSLFPowerPointExtractor(xmlSlideShow);
contentString = xslfPowerPointExtractor.getText();
break;
case APIConstants.TXT_EXTENSION:
case APIConstants.WSDL_EXTENSION:
case APIConstants.XML_DOC_EXTENSION:
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
StringBuilder contentBuilder = new StringBuilder();
while ((line = reader.readLine()) != null) {
contentBuilder.append(line);
}
contentString = contentBuilder.toString();
break;
}
} finally {
IOUtils.closeQuietly(inputStream);
}
} else if (Documentation.DocumentSourceType.INLINE.name().equals(sourceType)) {
String fileName = ((ResourceImpl) documentResource).getName();
String pathToDocFile = documentResource.getPath();
String pathToContent = pathToDocFile.substring(0, pathToDocFile.lastIndexOf(fileName)) + APIConstants.INLINE_DOCUMENT_CONTENT_DIR + RegistryConstants.PATH_SEPARATOR + fileName;
if (registry.resourceExists(pathToContent)) {
Resource contentResource = registry.get(pathToContent);
InputStream instream = null;
BufferedReader reader = null;
String line;
try {
instream = contentResource.getContentStream();
reader = new BufferedReader(new InputStreamReader(instream));
StringBuilder contentBuilder = new StringBuilder();
while ((line = reader.readLine()) != null) {
contentBuilder.append(line);
}
contentString = contentBuilder.toString();
} finally {
if (reader != null) {
IOUtils.closeQuietly(reader);
}
}
}
}
return contentString;
}
use of org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact in project carbon-apimgt by wso2.
the class APIUtilTest method testGetDocumentation.
@Test
public void testGetDocumentation() throws GovernanceException, APIManagementException {
PowerMockito.mockStatic(CarbonUtils.class);
ServerConfiguration serverConfiguration = Mockito.mock(ServerConfiguration.class);
Mockito.when(serverConfiguration.getFirstProperty("WebContextRoot")).thenReturn("/abc").thenReturn("/");
PowerMockito.when(CarbonUtils.getServerConfiguration()).thenReturn(serverConfiguration);
GenericArtifact genericArtifact = Mockito.mock(GenericArtifact.class);
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_TYPE)).thenReturn(DocumentationType.HOWTO.getType()).thenReturn(DocumentationType.PUBLIC_FORUM.getType()).thenReturn(DocumentationType.SUPPORT_FORUM.getType()).thenReturn(DocumentationType.API_MESSAGE_FORMAT.getType()).thenReturn(DocumentationType.SAMPLES.getType()).thenReturn(DocumentationType.OTHER.getType());
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_NAME)).thenReturn("Docname");
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_VISIBILITY)).thenReturn(null).thenReturn(Documentation.DocumentVisibility.API_LEVEL.name()).thenReturn(Documentation.DocumentVisibility.PRIVATE.name()).thenReturn(Documentation.DocumentVisibility.OWNER_ONLY.name());
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_SOURCE_TYPE)).thenReturn(Documentation.DocumentSourceType.URL.name()).thenReturn(Documentation.DocumentSourceType.FILE.name());
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_SOURCE_URL)).thenReturn("https://localhost");
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_FILE_PATH)).thenReturn("file://abc");
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_OTHER_TYPE_NAME)).thenReturn("abc");
APIUtil.getDocumentation(genericArtifact);
APIUtil.getDocumentation(genericArtifact);
APIUtil.getDocumentation(genericArtifact);
APIUtil.getDocumentation(genericArtifact);
APIUtil.getDocumentation(genericArtifact);
APIUtil.getDocumentation(genericArtifact);
}
use of org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact in project carbon-apimgt by wso2.
the class APIUtilTest method testVisibilityOfDoc.
@Test
public void testVisibilityOfDoc() throws Exception {
PowerMockito.mockStatic(CarbonUtils.class);
ServerConfiguration serverConfiguration = Mockito.mock(ServerConfiguration.class);
Mockito.when(serverConfiguration.getFirstProperty("WebContextRoot")).thenReturn("/abc").thenReturn("/");
PowerMockito.when(CarbonUtils.getServerConfiguration()).thenReturn(serverConfiguration);
GenericArtifact genericArtifact = Mockito.mock(GenericArtifact.class);
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_TYPE)).thenReturn(DocumentationType.HOWTO.getType()).thenReturn(DocumentationType.PUBLIC_FORUM.getType()).thenReturn(DocumentationType.SUPPORT_FORUM.getType()).thenReturn(DocumentationType.API_MESSAGE_FORMAT.getType()).thenReturn(DocumentationType.SAMPLES.getType()).thenReturn(DocumentationType.OTHER.getType());
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_NAME)).thenReturn("Docname");
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_SOURCE_TYPE)).thenReturn(Documentation.DocumentSourceType.URL.name()).thenReturn(Documentation.DocumentSourceType.FILE.name());
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_SOURCE_URL)).thenReturn("https://localhost");
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_FILE_PATH)).thenReturn("file://abc");
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_OTHER_TYPE_NAME)).thenReturn("abc");
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_VISIBILITY)).thenReturn(null);
Assert.assertEquals(APIUtil.getDocumentation(genericArtifact, "admin@wso2.com").getVisibility().name(), Documentation.DocumentVisibility.API_LEVEL.name());
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_VISIBILITY)).thenReturn(Documentation.DocumentVisibility.API_LEVEL.name());
Assert.assertEquals(APIUtil.getDocumentation(genericArtifact, "admin@wso2.com").getVisibility().name(), Documentation.DocumentVisibility.API_LEVEL.name());
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_VISIBILITY)).thenReturn(Documentation.DocumentVisibility.PRIVATE.name());
Assert.assertEquals(APIUtil.getDocumentation(genericArtifact, "admin@wso2.com").getVisibility().name(), Documentation.DocumentVisibility.PRIVATE.name());
Mockito.when(genericArtifact.getAttribute(APIConstants.DOC_VISIBILITY)).thenReturn(Documentation.DocumentVisibility.OWNER_ONLY.name());
Assert.assertEquals(APIUtil.getDocumentation(genericArtifact, "admin@wso2.com").getVisibility().name(), Documentation.DocumentVisibility.OWNER_ONLY.name());
}
Aggregations