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

1096 Computer.Model and Cpu.Model EnvironmentProperty share family and name #1098

Merged
merged 4 commits into from
Jun 25, 2022
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 @@ -54,8 +54,8 @@ public final boolean equals(Object object) {
if (!EnvironmentProperty.class.isInstance(object)) {
return false;
}
EnvironmentProperty os = (EnvironmentProperty) object;
return family.equals(os.family()) && name.equals(os.name());
EnvironmentProperty property = (EnvironmentProperty) object;
return family.equals(property.family()) && name.equals(property.name());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020 ArSysOp
* Copyright (c) 2020, 2022 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -8,7 +8,7 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* ArSysOp - initial API and implementation
* ArSysOp - initial API and implementation, further development
*******************************************************************************/
package org.eclipse.passage.lic.internal.base.inspection.hardware;

Expand All @@ -17,7 +17,7 @@
public abstract class Computer extends BaseEnvironmentProperty {

protected Computer(String name) {
super("system", name); //$NON-NLS-1$
super("computer", name); //$NON-NLS-1$
}

public static final class Manufacturer extends Computer {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*******************************************************************************
* Copyright (c) 2022 ArSysOp
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0/.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
package org.eclipse.passage.lic.internal.base.tests.inspection.hardware;
ruspl-afed marked this conversation as resolved.
Show resolved Hide resolved

import static org.junit.Assert.assertEquals;

import java.util.Arrays;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

import org.eclipse.passage.lic.api.inspection.EnvironmentProperty;
import org.eclipse.passage.lic.internal.base.inspection.hardware.BaseBoard;
import org.eclipse.passage.lic.internal.base.inspection.hardware.Computer;
import org.eclipse.passage.lic.internal.base.inspection.hardware.Cpu;
import org.eclipse.passage.lic.internal.base.inspection.hardware.Disk;
import org.eclipse.passage.lic.internal.base.inspection.hardware.Firmware;
import org.eclipse.passage.lic.internal.base.inspection.hardware.NetworkInterface;
import org.eclipse.passage.lic.internal.base.inspection.hardware.OS;
import org.junit.Test;

@SuppressWarnings("restriction")
public final class OshiPropertiesTest {

@Test
public void allDifferent() {
// having
AtomicInteger amount = new AtomicInteger(0);
// when
Set<EnvironmentProperty> all = eachAndEveryProperty(amount);
// then
assertEquals(amount.get(), all.size());
}

private Set<EnvironmentProperty> eachAndEveryProperty(AtomicInteger additions) {
return Arrays.asList(//
new BaseBoard.Manufacturer(), //
new BaseBoard.Model(), //
new BaseBoard.Serial(), //
new BaseBoard.Version(), //
new Computer.Manufacturer(), //
new Computer.Model(), //
new Computer.Serial(), //
new Cpu.Identifier(), //
new Cpu.Family(), //
new Cpu.Model(), //
new Cpu.Name(), //
new Cpu.ProcessorId(), //
new Cpu.Vendor(), //
new Disk.Model(), //
new Disk.Name(), //
new Disk.Serial(), //
new Firmware.Description(), //
new Firmware.Manufacturer(), //
new Firmware.Name(), //
new Firmware.ReleaseDate(), //
new Firmware.Version(), //
new NetworkInterface.DisplayName(), //
new NetworkInterface.HwAddress(), //
new NetworkInterface.MacAddress(), //
new NetworkInterface.Name(), //
new OS.BuildNumber(), //
new OS.Family(), //
new OS.Manufacturer(), //
new OS.Version()//
).stream()//
.peek(property -> additions.incrementAndGet())//
.collect(Collectors.toSet());

}
}