Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue fixed for remove unused object #30

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ private void forObject() {

private void forRoot() {
addPage.setEnabled(true);
removeUnusedObject.setEnabled(false);

renamePage.setEnabled(false);
deletePage.setEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
*
*
Expand Down Expand Up @@ -505,26 +507,28 @@ private void removeUnusedObject() {

}

public Map usedObject() {
public Map usedObject() {
Map<String, ArrayList<String>> attributeMap = new HashMap<>();
ArrayList<String> records = new ArrayList<String>();
ArrayList<String> records = new ArrayList<>();
try {
String testPlanPath = getProject().getLocation() + "/TestPlan";
String[] scenarioList = getFolderOrFileList(testPlanPath);
for (int i = 0; i < scenarioList.length; i++) {
String[] csvList = getFolderOrFileList(testPlanPath + "/" + scenarioList[i]);
for (int j = 0; j < csvList.length; j++) {
String csvFilePath = testPlanPath + "/" + scenarioList[i] + "/" + csvList[j];
for (String scenario : scenarioList) {
Path path = Paths.get(testPlanPath + "/" + scenario);
if(Files.isDirectory(path))
{
String[] csvList = getFolderOrFileList(testPlanPath + "/" + scenario);
for (String csv : csvList) {
String csvFilePath = testPlanPath + "/" + scenario + "/" + csv;
String[] values = null;
List objList = null;
try (BufferedReader br = new BufferedReader(new FileReader(csvFilePath))) {
String line;
while ((line = br.readLine()) != null) {
values = line.split(",");
if (!values[1].equals("Browser") && !values[1].equals("ObjectName") && (values.length == 7)) {//&& (values[1])!= "Browser" )
records.add(values[1]);
if (!(attributeMap.containsKey(values[6]))) {
attributeMap.put(values[6], new ArrayList<String>());
attributeMap.put(values[6], new ArrayList<>());
attributeMap.get(values[6]).add(values[1]);
} else {
attributeMap.get(values[6]).add(values[1]);
Expand All @@ -537,6 +541,7 @@ public Map usedObject() {
}
}
}
}

} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -584,7 +589,17 @@ public Map UnusedObject(Map<String, List> allSelectedObject, Map<String, List> u
}
}
}

else{
for(int s=0;s<allSelectedObject.get(selectedPage).size();s++)
{
if (!unUsedObject.containsKey(selectedPage.toString())) {
unUsedObject.put(selectedPage.toString(), new ArrayList<String>());
unUsedObject.get(selectedPage.toString()).add((String) allSelectedObject.get(selectedPage).get(s));
} else {
unUsedObject.get(selectedPage.toString()).add((String) allSelectedObject.get(selectedPage).get(s));
}
}
}
}
return unUsedObject;

Expand All @@ -606,7 +621,7 @@ public void deleteUnusedObject(String page, String object) {
Transformer t = tf.newTransformer();
StreamResult result = new StreamResult(new File(orFilePath));
t.transform(new DOMSource(document), result);
result.getOutputStream().close();
// result.getOutputStream().close();

} catch (Exception e) {
e.printStackTrace();
Expand Down
Loading