com.lyncode.pal.render.model.IndexModel Maven / Gradle / Ivy
The newest version!
package com.lyncode.pal.render.model;
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.lyncode.pal.model.PalTestGroup;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
public class IndexModel {
private final Collection groups;
public IndexModel(Collection groups) {
this.groups = new ArrayList(Collections2.transform(sort(new ArrayList(groups)), new Function() {
@Nullable
@Override
public GroupModel apply(@Nullable PalTestGroup input) {
return new GroupModel(input);
}
}));
}
private Collection sort(ArrayList palTestGroups) {
Collections.sort(palTestGroups);
return palTestGroups;
}
public int count (String status) {
int sum = 0;
for (GroupModel palTestGroup : groups) {
sum += palTestGroup.count(status);
}
return sum;
}
public Collection groups() {
return groups;
}
public boolean hasErrors () {
return count("Failed") > 0;
}
}