Skip to content

Commit

Permalink
Merge pull request #1098 from eclipse-passage/1096
Browse files Browse the repository at this point in the history
1096 Computer.Model and Cpu.Model EnvironmentProperty share family and name
  • Loading branch information
eparovyshnaya authored Jun 25, 2022
2 parents 00bdb13 + c4c38c5 commit 8467b7d
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 5 deletions.
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;

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());

}
}

0 comments on commit 8467b7d

Please sign in to comment.