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

Удалено дублирование тестового метода updateCommonModule, в пакет добавлено check #34

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*******************************************************************************
* Copyright (C) 2021, 1C-Soft LLC and others.
*
* 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:
* Aleksandr Kapralov - initial API and implementation
*******************************************************************************/
package com.e1c.v8codestyle.internal.md.itests;

import java.util.Map;
import java.util.Map.Entry;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EStructuralFeature;

import com._1c.g5.v8.bm.core.IBmObject;
import com._1c.g5.v8.bm.core.IBmTransaction;
import com._1c.g5.v8.bm.integration.AbstractBmTask;
import com._1c.g5.v8.bm.integration.IBmModel;
import com._1c.g5.v8.dt.core.platform.IDtProject;
import com._1c.g5.v8.dt.metadata.mdclass.CommonModule;
import com._1c.g5.v8.dt.metadata.mdclass.ReturnValuesReuse;
import com.e1c.g5.v8.dt.testing.check.CheckTestBase;

/**
* @author Aleksandr Kapralov
*
*/
public abstract class CheckMd
extends CheckTestBase
{

protected void updateCommonModule(IDtProject dtProject, String fqn, Map<EStructuralFeature, Boolean> types,
ReturnValuesReuse returnValueReuse, String newFqn)
{
IBmModel model = bmModelManager.getModel(dtProject);
model.execute(new AbstractBmTask<Void>("change type")
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
IBmObject object = transaction.getTopObjectByFqn(fqn);

for (Entry<EStructuralFeature, Boolean> entry : types.entrySet())
{
object.eSet(entry.getKey(), entry.getValue());
}

if (!(object instanceof CommonModule))
{
return null;
}

CommonModule module = (CommonModule)object;

if (returnValueReuse != null)
{
module.setReturnValuesReuse(returnValueReuse);
}

if (newFqn != null)
{
String[] fqnArray = newFqn.split("[.]");
if (fqnArray.length == 2)
{
module.setName(fqnArray[1]);
transaction.updateTopObjectFqn(object, newFqn);
}
}

return null;
}
});
waitForDD(dtProject);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,17 @@
* 1C-Soft LLC - initial API and implementation
* Aleksandr Kapralov - issue #14
*******************************************************************************/
package com.e1c.v8codestyle.md.itests;
package com.e1c.v8codestyle.md.check.itests;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.util.Map;
import java.util.Map.Entry;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.junit.Test;

import com._1c.g5.v8.bm.core.IBmObject;
import com._1c.g5.v8.bm.core.IBmTransaction;
import com._1c.g5.v8.bm.integration.AbstractBmTask;
import com._1c.g5.v8.bm.integration.IBmModel;
import com._1c.g5.v8.dt.core.platform.IDtProject;
import com._1c.g5.v8.dt.metadata.mdclass.CommonModule;
import com._1c.g5.v8.dt.metadata.mdclass.ReturnValuesReuse;
import com._1c.g5.v8.dt.validation.marker.Marker;
import com.e1c.g5.v8.dt.testing.check.CheckTestBase;
import com.e1c.v8codestyle.internal.md.itests.CheckMd;
import com.e1c.v8codestyle.md.check.CommonModuleNameClientServer;
import com.e1c.v8codestyle.md.check.CommonModuleType;

Expand All @@ -42,7 +32,7 @@
*
*/
public class CommonModuleNameClientServerTest
extends CheckTestBase
extends CheckMd
{

private static final String CHECK_ID = "common-module-name-client-server";
Expand Down Expand Up @@ -127,45 +117,4 @@ public void testCommonModuleNameClientServerReturnValueReuseCorrect() throws Exc
assertNull(marker);
}

private void updateCommonModule(IDtProject dtProject, String fqn, Map<EStructuralFeature, Boolean> types,
ReturnValuesReuse returnValueReuse, String newFqn)
{
IBmModel model = bmModelManager.getModel(dtProject);
model.execute(new AbstractBmTask<Void>("change type")
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
IBmObject object = transaction.getTopObjectByFqn(fqn);

for (Entry<EStructuralFeature, Boolean> entry : types.entrySet())
{
object.eSet(entry.getKey(), entry.getValue());
}

if (!(object instanceof CommonModule))
{
return null;
}

CommonModule module = (CommonModule)object;

module.setReturnValuesReuse(returnValueReuse);

if (newFqn != null)
{
String[] fqnArray = newFqn.split("[.]");
if (fqnArray.length == 2)
{
module.setName(fqnArray[1]);
transaction.updateTopObjectFqn(object, newFqn);
}
}

return null;
}
});
waitForDD(dtProject);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,17 @@
* 1C-Soft LLC - initial API and implementation
* Aleksandr Kapralov - issue #14
*******************************************************************************/
package com.e1c.v8codestyle.md.itests;
package com.e1c.v8codestyle.md.check.itests;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.util.Map;
import java.util.Map.Entry;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.junit.Test;

import com._1c.g5.v8.bm.core.IBmObject;
import com._1c.g5.v8.bm.core.IBmTransaction;
import com._1c.g5.v8.bm.integration.AbstractBmTask;
import com._1c.g5.v8.bm.integration.IBmModel;
import com._1c.g5.v8.dt.core.platform.IDtProject;
import com._1c.g5.v8.dt.metadata.mdclass.CommonModule;
import com._1c.g5.v8.dt.metadata.mdclass.ReturnValuesReuse;
import com._1c.g5.v8.dt.validation.marker.Marker;
import com.e1c.g5.v8.dt.testing.check.CheckTestBase;
import com.e1c.v8codestyle.internal.md.itests.CheckMd;
import com.e1c.v8codestyle.md.check.CommonModuleNameClient;
import com.e1c.v8codestyle.md.check.CommonModuleType;

Expand All @@ -42,7 +32,7 @@
*
*/
public class CommonModuleNameClientTest
extends CheckTestBase
extends CheckMd
{

private static final String CHECK_ID = "common-module-name-client";
Expand Down Expand Up @@ -127,45 +117,4 @@ public void testCommonModuleNameClientReturnValueReuseCorrect() throws Exception
assertNull(marker);
}

private void updateCommonModule(IDtProject dtProject, String fqn, Map<EStructuralFeature, Boolean> types,
ReturnValuesReuse returnValueReuse, String newFqn)
{
IBmModel model = bmModelManager.getModel(dtProject);
model.execute(new AbstractBmTask<Void>("change type")
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
IBmObject object = transaction.getTopObjectByFqn(fqn);

for (Entry<EStructuralFeature, Boolean> entry : types.entrySet())
{
object.eSet(entry.getKey(), entry.getValue());
}

if (!(object instanceof CommonModule))
{
return null;
}

CommonModule module = (CommonModule)object;

module.setReturnValuesReuse(returnValueReuse);

if (newFqn != null)
{
String[] fqnArray = newFqn.split("[.]");
if (fqnArray.length == 2)
{
module.setName(fqnArray[1]);
transaction.updateTopObjectFqn(object, newFqn);
}
}

return null;
}
});
waitForDD(dtProject);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,17 @@
* 1C-Soft LLC - initial API and implementation
* Aleksandr Kapralov - issue #14
*******************************************************************************/
package com.e1c.v8codestyle.md.itests;
package com.e1c.v8codestyle.md.check.itests;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.util.Map;
import java.util.Map.Entry;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.junit.Test;

import com._1c.g5.v8.bm.core.IBmObject;
import com._1c.g5.v8.bm.core.IBmTransaction;
import com._1c.g5.v8.bm.integration.AbstractBmTask;
import com._1c.g5.v8.bm.integration.IBmModel;
import com._1c.g5.v8.dt.core.platform.IDtProject;
import com._1c.g5.v8.dt.metadata.mdclass.CommonModule;
import com._1c.g5.v8.dt.metadata.mdclass.ReturnValuesReuse;
import com._1c.g5.v8.dt.validation.marker.Marker;
import com.e1c.g5.v8.dt.testing.check.CheckTestBase;
import com.e1c.v8codestyle.internal.md.itests.CheckMd;
import com.e1c.v8codestyle.md.check.CommonModuleNameGlobal;
import com.e1c.v8codestyle.md.check.CommonModuleType;

Expand All @@ -42,7 +32,7 @@
*
*/
public class CommonModuleNameGlobalTest
extends CheckTestBase
extends CheckMd
{

private static final String CHECK_ID = "common-module-name-global";
Expand Down Expand Up @@ -203,45 +193,4 @@ public void testCommonModuleNameServerGlobalReturnValueReuseCorrect() throws Exc
assertNull(marker);
}

private void updateCommonModule(IDtProject dtProject, String fqn, Map<EStructuralFeature, Boolean> types,
ReturnValuesReuse returnValueReuse, String newFqn)
{
IBmModel model = bmModelManager.getModel(dtProject);
model.execute(new AbstractBmTask<Void>("change type")
{
@Override
public Void execute(IBmTransaction transaction, IProgressMonitor monitor)
{
IBmObject object = transaction.getTopObjectByFqn(fqn);

for (Entry<EStructuralFeature, Boolean> entry : types.entrySet())
{
object.eSet(entry.getKey(), entry.getValue());
}

if (!(object instanceof CommonModule))
{
return null;
}

CommonModule module = (CommonModule)object;

module.setReturnValuesReuse(returnValueReuse);

if (newFqn != null)
{
String[] fqnArray = newFqn.split("[.]");
if (fqnArray.length == 2)
{
module.setName(fqnArray[1]);
transaction.updateTopObjectFqn(object, newFqn);
}
}

return null;
}
});
waitForDD(dtProject);
}

}