@Test public void testGetAssetType() { Path path = mock(Path.class); String fileName = "file."; when(path.getFileName()).thenReturn(fileName + RESOURCE_TYPE); String resourceType = displayer.getAssetType(path); assertEquals(RESOURCE_TYPE, resourceType); when(path.getFileName()).thenReturn(fileName + "fail"); resourceType = displayer.getAssetType(path); assertEquals(ShowAssetUsagesDisplayer.UNKNOWN_ASSET_TYPE, resourceType); assertNotEquals(RESOURCE_TYPE, resourceType); }
@Override public String getAssetType(Path path) { String extension = ""; String fileName = path.getFileName(); if (fileName.contains(".")) { extension = fileName.substring(fileName.lastIndexOf(".") + 1); } ResourceTypeDefinition typeDefinition = existingResourceTypes.get(extension); if (typeDefinition != null) { return typeDefinition.getShortName(); } return UNKNOWN_ASSET_TYPE; }
ShowAssetUsagesDisplayer implements ShowAssetUsagesDisplayerView.Presenter { @Override public String getAssetType(Path path) { String extension = ""; String fileName = path.getFileName(); if (fileName.contains(".")) { extension = fileName.substring(fileName.lastIndexOf(".") + 1); } ResourceTypeDefinition typeDefinition = existingResourceTypes.get(extension); if (typeDefinition != null) { return typeDefinition.getShortName(); } return UNKNOWN_ASSET_TYPE; } }
ShowAssetUsagesDisplayer implements ShowAssetUsagesDisplayerView.Presenter { @Override public String getAssetType(Path path) { String extension = ""; String fileName = path.getFileName(); if (fileName.contains(".")) { extension = fileName.substring(fileName.lastIndexOf(".") + 1); } ResourceTypeDefinition typeDefinition = existingResourceTypes.get(extension); if (typeDefinition != null) { return typeDefinition.getShortName(); } return UNKNOWN_ASSET_TYPE; } @Inject  ShowAssetUsagesDisplayer(ShowAssetUsagesDisplayerView view,
                                    TranslationService translationService,
                                    Caller<AssetsUsageService> assetsUsageServiceCaller); }
ShowAssetUsagesDisplayer implements ShowAssetUsagesDisplayerView.Presenter { @Override public String getAssetType(Path path) { String extension = ""; String fileName = path.getFileName(); if (fileName.contains(".")) { extension = fileName.substring(fileName.lastIndexOf(".") + 1); } ResourceTypeDefinition typeDefinition = existingResourceTypes.get(extension); if (typeDefinition != null) { return typeDefinition.getShortName(); } return UNKNOWN_ASSET_TYPE; } @Inject  ShowAssetUsagesDisplayer(ShowAssetUsagesDisplayerView view,
                                    TranslationService translationService,
                                    Caller<AssetsUsageService> assetsUsageServiceCaller); @PostConstruct void initialize(); void showAssetUsages(final Path path,
                                final String resourceFQN,
                                final ResourceType resourceType,
                                final Command okCommand,
                                final Command cancelCommand); void showAssetUsages(final String headerMessage,
                                final Path path,
                                final String resourceFQN,
                                final ResourceType resourceType,
                                final Command okCommand,
                                final Command cancelCommand); void showAssetUsages(final HTMLElement headerElement,
                                final Path path,
                                final String resourceFQN,
                                final ResourceType resourceType,
                                final Command okCommand,
                                final Command cancelCommand); void showAssetPartUsages(Path path,
                                    String resourceFQN,
                                    String resourcePart,
                                    PartType partType,
                                    Command okCommand,
                                    Command cancelCommand); void showAssetPartUsages(final String headerMessage,
                                    final Path path,
                                    final String resourceFQN,
                                    final String resourcePart,
                                    final PartType partType,
                                    final Command okCommand,
                                    final Command cancelCommand); void showAssetPartUsages(final HTMLElement headerElement,
                                    final Path path,
                                    final String resourceFQN,
                                    final String resourcePart,
                                    final PartType partType,
                                    final Command okCommand,
                                    final Command cancelCommand); @Override String getAssetType(Path path); @Override void onClose(); @Override void onOk(); @Override void onCancel(); }
ShowAssetUsagesDisplayer implements ShowAssetUsagesDisplayerView.Presenter { @Override public String getAssetType(Path path) { String extension = ""; String fileName = path.getFileName(); if (fileName.contains(".")) { extension = fileName.substring(fileName.lastIndexOf(".") + 1); } ResourceTypeDefinition typeDefinition = existingResourceTypes.get(extension); if (typeDefinition != null) { return typeDefinition.getShortName(); } return UNKNOWN_ASSET_TYPE; } @Inject  ShowAssetUsagesDisplayer(ShowAssetUsagesDisplayerView view,
                                    TranslationService translationService,
                                    Caller<AssetsUsageService> assetsUsageServiceCaller); @PostConstruct void initialize(); void showAssetUsages(final Path path,
                                final String resourceFQN,
                                final ResourceType resourceType,
                                final Command okCommand,
                                final Command cancelCommand); void showAssetUsages(final String headerMessage,
                                final Path path,
                                final String resourceFQN,
                                final ResourceType resourceType,
                                final Command okCommand,
                                final Command cancelCommand); void showAssetUsages(final HTMLElement headerElement,
                                final Path path,
                                final String resourceFQN,
                                final ResourceType resourceType,
                                final Command okCommand,
                                final Command cancelCommand); void showAssetPartUsages(Path path,
                                    String resourceFQN,
                                    String resourcePart,
                                    PartType partType,
                                    Command okCommand,
                                    Command cancelCommand); void showAssetPartUsages(final String headerMessage,
                                    final Path path,
                                    final String resourceFQN,
                                    final String resourcePart,
                                    final PartType partType,
                                    final Command okCommand,
                                    final Command cancelCommand); void showAssetPartUsages(final HTMLElement headerElement,
                                    final Path path,
                                    final String resourceFQN,
                                    final String resourcePart,
                                    final PartType partType,
                                    final Command okCommand,
                                    final Command cancelCommand); @Override String getAssetType(Path path); @Override void onClose(); @Override void onOk(); @Override void onCancel(); static String UNKNOWN_ASSET_TYPE; }